elasticsearch 搜索的时候怎么设置对搜索词不进行分词
資深大佬 : ThanksSirAlex 12
用了_analyze 接口,发现查询潮流的时候会这样
{ "tokens": [ { "token": "潮", "start_offset": 0, "end_offset": 1, "type": "<IDEOGRAPHIC>", "position": 0 }, { "token": "流", "start_offset": 1, "end_offset": 2, "type": "<IDEOGRAPHIC>", "position": 1 } ] }
但是我不希望他对搜索词进行分词
mapping 是这样的
mappings: { product: { properties: { title: { type: 'text', boost: 100, index: 'not_analyzed' }, # analyzer: 'ik_smart', index: 'not_analyzed' summary: { type: 'text', boost: 10, index: 'not_analyzed' }, # analyzer: 'ik_smart', index: 'not_analyzed' }, content: { type: 'text', boost: 10, index: 'not_analyzed' }, # analyzer: 'ik_smart', index: 'not_analyzed' }, class_name: { type: 'string', index: "not_analyzed" }, tags: { type: 'text', boost: 100, index: 'not_analyzed' }, # analyzer: 'ik_smart', index: 'not_analyzed' }, date: { type: 'date', format: "yyyy-MM-dd'T'HH:mm:ss.SSSZZ"} } } }
大佬有話說 (9)