phpsolrphp-7.1solr-query-syntaxsolr7

How to find exact keywords in solr search?


Actually I am facing one problem in solr search. There is an author field in which I stored two value like "deep kumar-singh" and "deep kumar singh". When I search the author:"deep kumar-singh" It returns both results. But I want only one result to be the exact one.

Here is my field description:

<field name="author" type="text_general" indexed="true" stored="true" multiValued="true"/>

I created authorFacet Field to get author facet.

<field name="authorFacet" type="string_ci" indexed="true" stored="false" multiValued="true"/>

When I choosed authorFacet it returns count 1 for both author Like:

deep kumar-singh(1)

deep kumar singh(1)

I want only one results to be exact.

How Can I get this?, Any suggestion would be very helpfull.


Solution

  • Change the fieldType of author to string from text_general and re-index the data. You would get the desired result. As the field which has the string as its type, it will not create any token of the word and would help to achieve the exact match.

    Also, the same can be analysed from the solr admin page. Go to the solr admin page. Select the core/collection. CLick on the analysis. You can select the field and check the index time token and query time if they are matching meeting your expectation.

    And with this you don't need 2 different fields for author. You can use one field which has string as field type can be used for both faceting and searching.

    solr exact match