【发布时间】:2020-03-27 20:14:35
【问题描述】:
我有一个由word_delimiter 过滤器填充的text 字段,使用keyword 标记器生成额外的标记,并且想搜索它们(match 操作),无论它们在查询字符串中的位置如何,例如
- 工作 - 找到文档:
GET test-position/_search
{
"query": {
"match": {
"title.keywords": {
"query": "yuio zxcv",
"operator": "or"
}}}}
- 不起作用 - 找不到文档,我真的不明白为什么?分析器为查询字符串生成相同的标记。
GET test-position/_search
{
"query": {
"match": {
"title.keywords": {
"query": "zxcv yuio",
"operator": "or"
}}}}
- 索引设置
PUT test-position
{
"settings": {
"number_of_shards": "1",
"number_of_replicas": "0",
"analysis": {
"filter": {
"word_delimiter_filter": {
"type": "word_delimiter_graph",
"catenate_words": "true",
"catenate_numbers": "true",
"catenate_all": "true",
"preserve_original": "true",
"generate_number_parts": "true"
}},
"analyzer": {
"wordpart_analyzer": {
"filter": [
"word_delimiter_filter"
],
"tokenizer": "keyword"
}}}},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "standard",
"fields": {
"keywords": {
"type": "text",
"analyzer": "wordpart_analyzer"
}}}}}}
- 测试文档
PUT test-position/_bulk
{"index":{}}
{"title":"asdf qwer yuio zxcv"}
【问题讨论】:
标签: elasticsearch