我一直在玩ElasticSearch以获得我的新项目.我已将默认分析器设置为使用ngram tokenfilter.这是我的elasticsearch.yml文件:
index:
analysis:
analyzer:
default_index:
tokenizer: standard
filter: [standard, stop, mynGram]
default_search:
tokenizer: standard
filter: [standard, stop]
filter:
mynGram:
type: nGram
min_gram: 1
max_gram: 10
Run Code Online (Sandbox Code Playgroud)
我创建了一个新索引并添加了以下文档:
$ curl -XPUT http://localhost:9200/test/newtype/3 -d '{"text": "one two three four five six"}'
{"ok":true,"_index":"test","_type":"newtype","_id":"3"}
Run Code Online (Sandbox Code Playgroud)
但是,当我使用查询text:hree
或text:ive
任何其他部分术语进行搜索时,ElasticSearch不会返回此文档.它仅在我搜索确切的术语(如text:two
)时返回文档.
我也尝试更改配置文件,以便default_search也使用ngram令牌过滤器,但结果是相同的.我在这里做错了什么,如何纠正?
我是一个错误相同此questuion。作为此问题的答案,我正在尝试为PUT索引映射设置正确的url,但不适用于我的实例:
$ cat mapping.json | http PUT myhost:9200/acastest/_mapping
Run Code Online (Sandbox Code Playgroud)
结果:
HTTP/1.1 400 Bad Request
Content-Length: 247
Content-Type: application/json; charset=UTF-8
{
"error": {
"reason": "Validation Failed: 1: mapping type is missing;",
"root_cause": [
{
"reason": "Validation Failed: 1: mapping type is missing;",
"type": "action_request_validation_exception"
}
],
"type": "action_request_validation_exception"
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud)
并尝试与此:
$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping
Run Code Online (Sandbox Code Playgroud)
结果:
HTTP/1.1 400 Bad Request
Content-Length: 3969
Content-Type: application/json; charset=UTF-8
{
"error": {
"reason": "Root mapping definition has unsupported parameters: …
Run Code Online (Sandbox Code Playgroud)