MatchAllQuery is a utility class which matches all documents. Each match is assigned a score of 0.0, so that in #composite queries, any document which matches against another part of the query will be #ranked higher than a document which matches only via the MatchAllQuery. For instance, below query can be used.
Lucene.Net.Search.MatchAllDocsQuery matchAllQuery = new Lucene.Net.Search.MatchAllDocsQuery();
hits = context.Searcher.Search(matchAllQuery));
I had a requirement where it's required to implement the result from the best possible result from full context.
We had created an index and in case of data not found wanted to get data from different templates.
Here “_path” field contains full item’s path where items’ name replaced with their ID
Executing the above query will return your items under the SitecoreTemplateName.TemplateABC item in the result(if you have indexed that section):
In case if result not found or wanted to show from different template - We should use the
Lucene.Net.Search.MatchAllDocsQuery class and create the appropriate query.
For more details:-
No comments:
Post a Comment