Skip to main content
add debug information for solr
Source Link
x3mxray
  • 3.2k
  • 12
  • 33

You can do it with:

var queryableResultItems = context.GetQueryable<GlobalSearchResultItem >()
                    .Where(expression)
                    .OrderByDescending(x => x["termfreq(content_t, \""+ term+ "\")"])

But I suggest you to setup logic that you need on Solr side. Sorl sorts the results based on the basis of the relevancy of the term present in the field OOTB (it uses tf-idf algorithm to calculate scoring).

You should check query analizer forof your field type in managed-schema (your field should be tokenized):

<analyzer type="query">
      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
      ...
    </analyzer>

enter image description here

You can check it in Solr by adding "score" in fl textbox. You can also see how scoring is calculating by checking debugQuery: enter image description here

As you can see, Solr uses termFreq OOTB while scoring: enter image description here

You can do it with:

var queryableResultItems = context.GetQueryable<GlobalSearchResultItem >()
                    .Where(expression)
                    .OrderByDescending(x => x["termfreq(content_t, \""+ term+ "\")"])

But I suggest you to setup logic that you need on Solr side. Sorl sorts the results on the basis of the relevancy of the term present in the field OOTB (it uses tf-idf algorithm to calculate scoring).

You should check query analizer for your field type in managed-schema (your field should be tokenized):

<analyzer type="query">
      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
      ...
    </analyzer>

enter image description here

You can do it with:

var queryableResultItems = context.GetQueryable<GlobalSearchResultItem >()
                    .Where(expression)
                    .OrderByDescending(x => x["termfreq(content_t, \""+ term+ "\")"])

But I suggest you to setup logic that you need on Solr side. Sorl sorts the results based on the relevancy of the term present in the field OOTB (it uses tf-idf algorithm to calculate scoring).

You should check query analizer of your field type in managed-schema (your field should be tokenized):

<analyzer type="query">
      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
      ...
    </analyzer>

enter image description here

You can check it in Solr by adding "score" in fl textbox. You can also see how scoring is calculating by checking debugQuery: enter image description here

As you can see, Solr uses termFreq OOTB while scoring: enter image description here

Source Link
x3mxray
  • 3.2k
  • 12
  • 33

You can do it with:

var queryableResultItems = context.GetQueryable<GlobalSearchResultItem >()
                    .Where(expression)
                    .OrderByDescending(x => x["termfreq(content_t, \""+ term+ "\")"])

But I suggest you to setup logic that you need on Solr side. Sorl sorts the results on the basis of the relevancy of the term present in the field OOTB (it uses tf-idf algorithm to calculate scoring).

You should check query analizer for your field type in managed-schema (your field should be tokenized):

<analyzer type="query">
      <tokenizer class="solr.WhitespaceTokenizerFactory"/>
      ...
    </analyzer>

enter image description here