How do I specify a different analyzer than my index_analyzer at query time?


(Qiulang) #1

I set multi-analyzers like this

curl -X PUT "localhost:9200/sentences" -H 'Content-Type: application/json' -d'
{
    "mappings": {
        "_doc": {
            "properties": {
                "content": {
                    "type": "text",
                    "analyzer":"smartcn",
                    "term_vector": "yes",
                    "fields": {
                        "ik":{
                            "analyzer": "ik_max_word",
                            "search_analyzer": "ik_smart",
                            "type": "text"
                        },
                        "jieba":{
                            "analyzer": "jieba_index",
                            "search_analyzer": "jieba_search",
                            "type": "text"
                        }
                    }
                }
            }
        }
    }
}
'

So how do I specify a different analyzer than smartcn at query time ?

POST sentences/_doc/_search
{
 "query" : { "match" : { 
 	"content" :{"query":"some Chinese text","operator": "and"}
 }}
}

(Alexander Reelsen) #2

The match query supports an analyzer field that you can use to refer to another search analyzer.

Hope this helps!


(Qiulang) #3

So just {"query":"some Chinese text","operator": "and","analyzer" : "smartcn"}

man, I should think of that.

Thanks!


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.