Domanda

avevo creato una query XML che inviavo al mio servizio di ricerca di SharePoint, che stava tornando alcuni risultati. Poi ho tirato il testo della query SQL fuori di esso e iniziato a utilizzare con il modello a oggetti e ora non sta funzionando. Ti sembra che sto facendo qualcosa di sbagliato in base al codice qui sotto?

XML Query (restituisce i risultati):

<QueryPacket xmlns="urn:Microsoft.Search.Query" Revision="1000">
                                    <Query domain="QDomain">
                                     <SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats>
                                     <Context>
                                       <QueryText language="en-US" type="MSSQLFT"><![CDATA[ SELECT Title, Rank, owsPublished1,owsSocialx0020Networkx0020Update, Description, Write, Path FROM scope()   ORDER BY "Rank" DESC ]]></QueryText>
                                     </Context>
                                     <Range><StartAt>1</StartAt><Count>20</Count></Range>
                                     <EnableStemming>false</EnableStemming>
                                     <TrimDuplicates>true</TrimDuplicates>
                                     <IgnoreAllNoiseQuery>true</IgnoreAllNoiseQuery>
                                     <ImplicitAndBehavior>true</ImplicitAndBehavior>        <IncludeRelevanceResults>true</IncludeRelevanceResults>                               <IncludeSpecialTermResults>true</IncludeSpecialTermResults>                        
<IncludeHighConfidenceResults>true</IncludeHighConfidenceResults>
                                    </Query></QueryPacket>

codice del modello oggetto (Non):

        SPSite site = new SPSite("http://sp-dev/");
        ServerContext sc = ServerContext.GetContext(site);
        FullTextSqlQuery ftq = new FullTextSqlQuery(sc);
        string querySQL = @"SELECT Title, Rank, owsPublished1,owsSocialx0020Networkx0020Update, Description, Write, Path FROM scope()   ORDER BY ""Rank"" DESC ";

        ftq.QueryText = querySQL;;
        ResultTableCollection results = ftq.Execute();
È stato utile?

Soluzione

Avete bisogno di almeno aggiungere:

ftq.EnableStemming = false;
ftq.TrimDuplicates = true;
ftq.IgnoreAllNoiseQuery = true;
ftq.KeywordInclusion = KeywordInclusion.AllKeywords;

per almeno fare un confronto equo tra i due metodi. Poi, si può anche provare:

ftq.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top