Relevance and Query Concept in Solr

watch Solr is an amazing search engine developed by Apache, in this article we will learn few concepts of Solr regarding different query and how to improve the relevance.

  • Different type of query, Dismax and eDismax
  • Using token and boolean query improve the search relevance
  • Highlighting feature in Solr

source site de rencontre sri lankaise Q. Difference in simple query parser and Dismax and eDismax query parser

conocer chicas en san pedro sula A: Dismax is an abbreviation of Disjoint Max and it is a popular query mode with Solr. Default query parse in Solr is quite stupid, it doesn’t support the syntactic parsing of the query and doesn’t handles the exceptions smoothly. If you put some extra character, it might throw exception. Where as Dismax query parse is pretty safe with not to get exceptions, more over it understand the query with logical operator, weight allocation and results accordingly. Like ( “Caner” AND “Blood” ) OR “Blood Cancer”^2 : will be processed by Dismax.

The Extended DisMax Query Parser ( eDisMax) is a robust parser designed to process advanced user input directly. It searches for the query words across multiple fields with different boosts, based on the significance of each field. Additional options let you influence the score based on rules specific to each use case (independent of user input). Q. Using Token based searching in Solr

opzioni binarie lungo periodo A. It’s simple 🙂 You should prepare a corpus of words and phrases and assign different weight to them based on relevance and importance to your domain. Now once you get the search query, use N gram tokenizer to replace the tokens by boosted factor based one their relevance or weight, and use the AND and OR operation wisely.

Example “Blood cancer symptoms”, can be converted into “Blood Cancer symptoms”^100 OR (“Blood caner” AND symptom)^10 OR (Blood AND Cancer AND symptom)^5 OR “Blood Cancer”

This query will result you much relevant results than simple query.

Q. Highlighter to highlight the matched keywords A : First to set the highlighting while making query, it’s very simple you just to query.setHightlight(true) and you can also set other parameters.


query.setParam(“hl.fl”, highlightingField);



query.setParam(“hl.simple.pre”,” source site “);


“);        query.setParam(“hl.snippets”,”2″);

Now when you get the response, you have to extract the snippets from response. It is normally a Map of highlightings which returns the list of String (which are snippets) by passing the key as identifier field.

if (response.getHighlighting()!=null

&& response.getHighlighting().get(object.getId().toString()) != null) {

List highlightSnippets = response.getHighlighting().get(object.getId().toString()).get(Highlighted_Field_Name);


StringBuilder contentToShow=new StringBuilder();

for(String snippet:highlightSnippets){

if(contentToShow.length()                                contentToShow.append(snippet).append(” …”);
} else {

Refer at here

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *