When examine matches a document from your search term, it also calculates a 'score' indicating how well the document matches the term, and it is by this score that Examine orders the results, eg the most relevant match first.
When you are building your custom examine query you can add the OrderBy or OrderByDescending option at the end to specify the field to order by.
eg:
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var criteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
var searchTerm = "fish"; //or read from form post / querystring etc
//build other criteria for your search
var query = criteria.Field("bodyText",searchTerm).Or().Field("title",searchTerm);
// ordering
query.And().OrderByDescending(new string[] {"title"});
//compile and get results
var results = searcher.Search(query.Compile());
The score is calculated by the number of times the search term has been found in the field(s) you're searching against.
For example, let's say you're searching on the keyword "crow" and you're searching for the keyword in 3 different fields, i.e. Name, SEO Title, SEO Description.
If a result has the keyword "crow" once in the Name, SEO Title and SEO Description fields will produce the same score as another result with the keyword once in Name, 3 times in SEO Title and 8 times in SEO Description; HOWEVER, will be a higher score than a result that has the keyword once in Name and 5 times in SEO Title and not mentioned once in SEO Description.
Examine search result default sort order
Hello,
What is the default sort order when we use Examine mechanism?
How the data will be sorted, based on ID or any text.
can anyone guide me what will be the default order and can we customize the default result order?
Hi Nilesh
When examine matches a document from your search term, it also calculates a 'score' indicating how well the document matches the term, and it is by this score that Examine orders the results, eg the most relevant match first.
When you are building your custom examine query you can add the OrderBy or OrderByDescending option at the end to specify the field to order by.
eg:
Thanks for the reply.
But how score is calculated?
Hi Nilesh
The score is calculated by the number of times the search term has been found in the field(s) you're searching against.
For example, let's say you're searching on the keyword "crow" and you're searching for the keyword in 3 different fields, i.e. Name, SEO Title, SEO Description.
If a result has the keyword "crow" once in the Name, SEO Title and SEO Description fields will produce the same score as another result with the keyword once in Name, 3 times in SEO Title and 8 times in SEO Description; HOWEVER, will be a higher score than a result that has the keyword once in Name and 5 times in SEO Title and not mentioned once in SEO Description.
I hope that makes sense.
Regards
Joshua
Scoring is quite complex - you can read about how Lucene (which sits behind Examine) calculates the score:
http://www.lucenetutorial.com/advanced-topics/scoring.html
Note you can boost terms to increase their "weight" if you wish.
is working on a reply...