Django-Haystack autoquery gives strange results with solr backend -
i using django 1.5 along haystack 2.1.0.
while using auto-query on 1 of models found following behavior.
test_search = "charles ken" searchqueryset().models(foo, foosome, foogone).auto_query(test_search)
the above query gives multiple results.
test_search = "charles k" searchqueryset().models(foo, foosome, foogone).auto_query(test_search)
the above query gives no results. doing wrong ?
edit :
the field in concern edge_ngram
<fieldtype name="edge_ngram" class="solr.textfield" positionincrementgap="1"> <analyzer type="index"> <tokenizer class="solr.whitespacetokenizerfactory" /> <filter class="solr.lowercasefilterfactory" /> <filter class="solr.worddelimiterfilterfactory" generatewordparts="1" generatenumberparts="1" catenatewords="0" catenatenumbers="0" catenateall="0" splitoncasechange="1"/> <filter class="solr.edgengramfilterfactory" mingramsize="2" maxgramsize="15" side="front" /> </analyzer> <analyzer type="query"> <tokenizer class="solr.whitespacetokenizerfactory" /> <filter class="solr.lowercasefilterfactory" /> <filter class="solr.worddelimiterfilterfactory" generatewordparts="1" generatenumberparts="1" catenatewords="0" catenatenumbers="0" catenateall="0" splitoncasechange="1"/> </analyzer> </fieldtype>
you need change mingramsize here 1
<fieldtype name="edge_ngram" class="solr.textfield" positionincrementgap="1"> <analyzer type="index"> <tokenizer class="solr.whitespacetokenizerfactory" /> <filter class="solr.lowercasefilterfactory" /> <filter class="solr.worddelimiterfilterfactory" generatewordparts="1" generatenumberparts="1" catenatewords="0" catenatenumbers="0" catenateall="0" splitoncasechange="1"/> <filter class="solr.edgengramfilterfactory" mingramsize="1" maxgramsize="15" side="front" /> </analyzer> <analyzer type="query"> <tokenizer class="solr.whitespacetokenizerfactory" /> <filter class="solr.lowercasefilterfactory" /> <filter class="solr.worddelimiterfilterfactory" generatewordparts="1" generatenumberparts="1" catenatewords="0" catenatenumbers="0" catenateall="0" splitoncasechange="1"/> </analyzer> </fieldtype>
but recommend have mingramsize=2 or 3 avoid many indexes.
Comments
Post a Comment