Home > Backend Development > PHP Tutorial > What if the Elasticsearch ik plug-in can accurately search Chinese?

What if the Elasticsearch ik plug-in can accurately search Chinese?

WBOY
Release: 2016-08-04 09:21:49
Original
1227 people have browsed it

The following index is generated in Elasticsearch(ik)
The example structure is as follows

<code>      array(5) {
        ["_index"]=>
        string(10) "n_index"
        ["_type"]=>
        string(9) "n_type"
        ["_id"]=>
        string(20) "AVXdrZDVceqO8Q-vidP2"
        ["_score"]=>
        float(0.5171687)
        ["_source"]=>
        array(5) {
          ["id"]=>
          int(111)
          ["title"]=>
          string(82) "北京16款现代300顶级配置"
        }
      }```
      
      
比如我建了好多这样的索引
title字段列表如下
"北京16款现代300顶级配置"
"16款现代300北京顶级配置"
"北京16款起亚顶级配置"
"北京16款300顶级配置"
。。。


如何能实现查询结果返回以下几条


"北京16款现代300顶级配置"
"16款现代300北京顶级配置"</code>
Copy after login
Copy after login

Reply content:

The following index is generated in Elasticsearch(ik)
The example structure is as follows

<code>      array(5) {
        ["_index"]=>
        string(10) "n_index"
        ["_type"]=>
        string(9) "n_type"
        ["_id"]=>
        string(20) "AVXdrZDVceqO8Q-vidP2"
        ["_score"]=>
        float(0.5171687)
        ["_source"]=>
        array(5) {
          ["id"]=>
          int(111)
          ["title"]=>
          string(82) "北京16款现代300顶级配置"
        }
      }```
      
      
比如我建了好多这样的索引
title字段列表如下
"北京16款现代300顶级配置"
"16款现代300北京顶级配置"
"北京16款起亚顶级配置"
"北京16款300顶级配置"
。。。


如何能实现查询结果返回以下几条


"北京16款现代300顶级配置"
"16款现代300北京顶级配置"</code>
Copy after login
Copy after login

<code>GET /_search
{
    "query": {
        "match_phrase": {  //match分词搜索命中 match_phrase分词全匹配
            "title": "北京16款现代300顶级配置"
        }
    }
}
</code>
Copy after login

Try this structured query

  • List items

  • List items

  • List items

Currently, according to the example of https://github.com/medcl/elasticsearch-analysis-ik, you can find the keywords separated from the word segmentation, but for example, I added curl -XPOST http://localhost:9200/index/fulltext/ 4 -d'
{"content":"The suspect who was shot by an Asian man at the Chinese Consulate in Los Angeles has surrendered"}
'
I want to check this line through "Chinese Man", can this es be achieved? Does it require special configuration or (this configuration in the example cannot be implemented)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template