0
時,如何引用多場我無法使用導航標記訪問多場elasticsearch - 建立查詢
我的映射:
{
"mappings":{
"document":{
"properties":{
"tags":{
"type":"object",
"properties":{
"title":{
"fields":{
"partial":{
"search_analyzer":"main",
"index_analyzer":"partial",
"type":"string"
},
"title":{
"type":"string",
"analyzer":"main"
},
"title2":{
"type":"string",
"analyzer":"main"
}
},
"type":"multi_field"
}
}
}
}
}
},
"settings":{
"analysis":{
"filter":{
"name_ngrams":{
"side":"front",
"max_gram":50,
"min_gram":2,
"type":"edgeNGram"
},
"name_ngrams_back":{
"side":"back",
"max_gram":50,
"min_gram":2,
"type":"edgeNGram"
},
"name_middle_ngrams":{
"type":"nGram",
"max_gram":50,
"min_gram":2
}
},
"analyzer":{
"main":{
"filter": ["standard", "lowercase", "asciifolding"],
"type": "custom",
"tokenizer": "standard"
},
"partial":{
"filter":["standard","lowercase","asciifolding","name_ngrams"],
"type": "custom",
"tokenizer": "standard"
}
}
}
}
}
測試數據:
curl -XPUT localhost:9200/testindex/document/1 -d '{"title": "Fight for your life"}'
curl -XPUT localhost:9200/testindex/document/2 -d '{"title": "Fighting for your life"}'
curl -XPUT localhost:9200/testindex/document/3 -d '{"title": "Will you just start the fight"}'
搜索:
curl -XGET 'localhost:9200/testindex/document/_search?q=title:life&pretty=1' // Ok
curl -XGET 'localhost:9200/testindex/document/_search?q=document.title:life&pretty=1' // Ok
// Return 0 hits. I expect this to return same result as the above queries.
curl -XGET 'localhost:9200/testindex/document/_search?q=title.title2:life&pretty=1'
curl -XGET 'localhost:9200/testindex/document/_search? q=document.title.title2:life&pretty=1'
如何在構建查詢時引用多個字段?
謝謝* 2; – Kennedy