ruby on rails 4 - “Exact” phrase matching with wildcards + SOLR -
actually want exact matching 'b t patil' , have created following filed-type
<fieldtype name="text_name" class="solr.textfield" omitnorms="false"> <analyzer> <tokenizer class="solr.whitespacetokenizerfactory"/> <filter class="solr.worddelimiterfilterfactory" preserveoriginal="1" splitonnumerics="1" splitoncasechange="1" catenatewords="1" catenatenumbers="1" catenateall="1" generatewordparts="1" generatenumberparts="1" stemenglishpossessive="1" /> </analyzer> </fieldtype>
also text field , ngram filed applied on string. whenever entering b t patil
query in field @ time returning me irrelevant results i.e returning me
b t agrawal jaykumar b. patil bhaskar b. patil
i expecting should return me b t patil or b.t.patil or b. t. patil
results. need change tokenizer ?
you can try this. create field type exact match following
<fieldtype name="text_exact" class="solr.textfield" positionincrementgap="100"> <analyzer type="index"> <tokenizer class="solr.keywordtokenizerfactory"/> <filter class="solr.lowercasefilterfactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.keywordtokenizerfactory"/> <filter class="solr.lowercasefilterfactory"/> </analyzer> </fieldtype> <dynamicfield name="*_exact" stored="false" type="text_exact" multivalued="true" indexed="true"/>
boost field , phrase field comparatively text , text_name fields.
searchable text :field1_exact, as: :field1_exact, default_boost: 5.0 field1 end text :field1_name, as: :field1_name, default_boost: 3.0 field1 end end sunspot.search(model) fulltext 'b t patil'do fields (field1_exact, field1_name, field1) phrase_fields (field1_exact: 8, field1_name: 4, field1: 2) end end
give least priority ngram fields if any.
Comments
Post a Comment