另外,我有部分搜索工作,我可以搜索所有字段.但是我无法在映射所有字段的搜索上使用部分匹配.
当我使用部分匹配时,这将返回我的名字:
GET /_search?pretty=true
{
"query": {
"match": {
"FullName": "andon"
}
}
}
Run Code Online (Sandbox Code Playgroud)
此搜索在所有字段上运行,但不进行部分匹配(0次点击):
GET /_search?pretty=true
{
"query": {
"match": {
"_all": "andon"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何将部分匹配与所有字段和类型的搜索相结合,我需要做些什么?我有很多字段和类型,所以我希望避免必须手动指定它们.
如果它有任何区别,我将从连接到SQL的River插入我的数据.
编辑: 我现在在我的映射中有_all字段.它似乎没有任何区别.
PUT /contact/
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"my_ngram_analyzer" : {
"tokenizer" : "my_ngram_tokenizer"
}
},
"tokenizer" : {
"my_ngram_tokenizer" : {
"type" : "nGram",
"min_gram" : "1",
"max_gram" : "10"
}
}
}
}
},
"mappings": {
"_default_": {
"_all" : {"enabled" : true},
"properties" : {
"Description":{"type":"string","store":"yes", "index_analyzer": "my_ngram_analyzer"},
"OfficePhone":{"type":"string","store":"yes"},
"Email":{"type":"string","store":"yes", "index_analyzer": "my_ngram_analyzer"},
"FullName":{"type":"string","store":"yes", "index_analyzer": "my_ngram_analyzer"},
"ReportsTo":{"type":"string","store":"yes"},
"Department":{"type":"string","store":"yes", "index_analyzer": "my_ngram_analyzer"},
"Title":{"type":"string","store":"yes", "index_analyzer": "my_ngram_analyzer"}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
Ale*_*vik 24
在_all-场工程通过采取所有字段的文本,通过他们通过分析仪_all(这是standard除非被覆盖),那么指数所产生的条款.
它并没有采取任何条款被分析为等领域取得和他们都推到同一个领域.
因此,您必须覆盖_all-field以使用自定义分析器.
但!我不认为你真的想这样做.你会得到一个更大的索引.其_all是在时间方便,但它通常是更好地控制字段在搜索时搜索的内容.
因此,而不是做match对_all,你可能想使用multi_match,并指定你的领域.您还可以考虑copy_to是否使用1.0.
| 归档时间: |
|
| 查看次数: |
26199 次 |
| 最近记录: |