Django Haystack : search for a term with and without accents

前端 未结 3 1683
日久生厌
日久生厌 2021-01-01 04:32

I\'m implementing a search system onto my django project, using django haystack. The problem is that some fields in my models have some french accents, and I would like to f

3条回答
  •  攒了一身酷
    2021-01-01 05:10

    Yes, you're on the right track here. Sometimes you do want to store fields multiple times, with different transformations applied.

    An example of this in my application is that I have two title fields. One for searching which gets stemmed (the process by which test ~= test ~= tester), and another for sorting which is left alone (the stemming interferes with the sort order).

    This is an analogous case.

    In my schema.xml this is handled by:

    
    
    

    The type "string" is responsible for storing the "as-is" version of the title.

    By the way, it you're stripping accents just to make words easier to search for, this is something that might be worth looking into: http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.ISOLatin1AccentFilterFactory

提交回复
热议问题