Elasticsearch fuzziness breaks plural

时间:2017-07-12 07:55:55

标签: elasticsearch

I'm trying to use Elasticsearch with these settings:

"settings" : { 
    "number_of_shards" : 1,
    "number_of_replicas" : 0,
    "analysis" : { 
        "filter": {
            "english_stop": {
              "type":       "stop",
              "stopwords":  "_english_"
            },  
            "english_stemmer": {
              "type":       "stemmer",
              "language":   "english" 
            },  
            "english_possessive_stemmer": {
              "type":       "stemmer",
              "language":   "possessive_english" 
            }   
        },  
        "analyzer" : { 
            "default" : { 
                "tokenizer" : "standard",
                "filter": [
                    "standard",
                    "english_possessive_stemmer",
                    "lowercase",
                    "english_stop",
                    "english_stemmer"
                ]   
            }   
        }   
    }   
},
"mappings": {
    "_default_": {
        "properties" : { 
          "description" : { 
            "type" : "text",
            "analyzer" : "default",
            "search_analyzer": "default"
          } 
        }
    }
} 

And this search query:

"query": {
    "query_string" : { 
        "query" : "signed~ golf~ hats~",
        "fuzziness" : 'AUTO'
    }   
}   

I am trying to search two queries: signed~ golf~ hat~ and signed~ golf~ hats~. Because of the analyzer, I would expect both search results to return the same for plural and singular hats, but they don't. And I think the reason why is because of the fuzziness operator ~. When I remove this, the search results are the same, but then misspellings don't work. Is there a way I could get fuzzy search so that misspellings can be caught but my plural/singular searches return the same results?

0 个答案:

没有答案