Solr.Net query returns false results

I am trying to find a Solr instance with Solr.Net . I have a body field that is defined in the schema as:

 <field name="body" type="text_general" indexed="true" stored="true" omitNorms="true"/> 

text_general uses solr.StandardTokenizerFactory in the schema and is defined as:

 <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <!-- in this example, we will only use synonyms at query time <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> --> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> </fieldType> 

(I did not change anything with this type of field, this is the one I got with the default solr setting)

I am trying to query records for the search query LISTBU5.RCV , it returns me results containing LISTBU4.RCV . How:

 Items left on queue: \\111.11.11.11\Lists\SAVELIST\ABC2\LISTBU4.RCV 

False Result: The number at the end of the search query is different

My code for the request:

 SolrQueryByField solrQuery = new SolrQueryByField("body", searchTerm); var result = solr.Query(solrQuery, new SolrNet.Commands.Parameters.QueryOptions { Rows = 100, // Start = 0, OrderBy = new[] { new SortOrder("ID", Order.DESC) }, }); 

But if I use Text Query, for example:

 SolrQuery solrQuery = new SolrQuery("(body:" + "\"" + searchTerm + "\")"); 

It returns accurate results. I know that creating a text query is not recommended in Solr.Net , but what should I do?

I am using SolrNet.dll version 0.4.0.2002 with the version of Solr Instance 4.4.0 .

+1
source share
2 answers

I managed to find a problem. The reason I got the false result was due to the SortOrder specified in my query options. This has been canceled by default SortOrder based on relevance score. I just changed my query parameters, for example:

 var result = solr.Query(solrQuery, new SolrNet.Commands.Parameters.QueryOptions { Rows = 100, // Start = 0, OrderBy = new[] { new SortOrder("score", Order.DESC), new SortOrder("ID", Order.DESC) }, }); 

new SortOrder("score", Order.DESC) will cause the results to be returned based on a relevancy score, and then it will sort based on the identifier.

I'm not sure why SortOrder was overridden when sending a text request to SOLR. But it looks like he will pick the top 100 lines with an exact expression instead of false positives.

I will simply leave this answer for future visitors and will accept any future answer if it provides the basis for this search behavior.

+2
source

It seems that the two requests were different, because in the first example the term was symbolized , but not the second, which was protected by a double quote. Could you try:

 SolrQueryByField solrQuery = new SolrQueryByField("body", "\""+searchTerm+"\""); 

This may give you the same result as the second query (if you disregard the order). E.I.V.

+1
source

All Articles