【问题标题】:Wild card search required instead of specific field name in elasticsearch需要通配符搜索而不是弹性搜索中的特定字段名称
【发布时间】:2016-06-22 21:41:07
【问题描述】:

我正在开发弹性搜索 2.3.3。在查询搜索时,我仅在指定字段名称时才获得结果。即

GET /mydocs/_search?q=file.content:cat

但我需要在不提供字段名称的情况下进行搜索。怎么可能?

来自http://localhost:9200/mydocs的回复

 {  
 "mydocs":{  
  "aliases":{  

  },
  "mappings":{  
     "indexdocument":{  
        "properties":{  
           "docLocation":{  
              "type":"string",
              "index":"not_analyzed",
              "store":true
           },
           "documentType":{  
              "type":"string",
              "store":true
           },
           "file":{  
              "type":"attachment",
              "fields":{  
                 "content":{  
                    "type":"string",
                    "analyzer":"full"
                 },
                 "author":{  
                    "type":"string"
                 },
                 "title":{  
                    "type":"string",
                    "term_vector":"with_positions_offsets",
                    "analyzer":"full"
                 },
                 "name":{  
                    "type":"string"
                 },
                 "date":{  
                    "type":"date",
                    "format":"strict_date_optional_time||epoch_millis"
                 },
                 "keywords":{  
                    "type":"string"
                 },
                 "content_type":{  
                    "type":"string"
                 },
                 "content_length":{  
                    "type":"integer"
                 },
                 "language":{  
                    "type":"string"
                 }
              }
           },
           "filePermissionInfo":{  
              "properties":{  
                 "accessControlType":{  
                    "type":"string",
                    "store":true
                 },
                 "accountValue":{  
                    "type":"string",
                    "store":true
                 },
                 "fileSystemRights":{  
                    "type":"string",
                    "store":true
                 },
                 "isInherited":{  
                    "type":"string",
                    "store":true
                 }
              }
           },
           "id":{  
              "type":"double",
              "store":true
           },
           "lastModifiedDate":{  
              "type":"date",
              "store":true,
              "format":"strict_date_optional_time||epoch_millis"
           },
           "title":{  
              "type":"string",
              "store":true,
              "term_vector":"with_positions_offsets"
           }
        }
     }
  },
  "settings":{  
     "index":{  
        "creation_date":"1466482894271",
        "analysis":{  
           "filter":{  
              "snowball":{  
                 "type":"snowball",
                 "language":"English"
              }
           },
           "analyzer":{  
              "full":{  
                 "filter":[  
                    "lowercase",
                    "snowball"
                 ],
                 "type":"custom",
                 "tokenizer":"standard"
              }
           }
        },
        "number_of_shards":"5",
        "number_of_replicas":"1",
        "uuid":"PpxcRl29QTCPtFcsd3PHtw",
        "version":{  
           "created":"2030399"
        }
     }
  },
  "warmers":{  

  }
 }
}

【问题讨论】:

  • 你能用GET /mydocs的回复更新你的问题吗?
  • 您想对所有字符串字段执行querystring 查询吗? elastic.co/guide/en/elasticsearch/reference/current/…
  • @RussCam 用户不知道任何字段名称,他们将输入要搜索的文本(我使用的是 kibana)。我们在内部需要检查给定的文本是否包含在标题或附加内容中。可以使用kibana吗?
  • 您应该能够将索引更改为index.query.default_field 以指向另一个字段,并在索引时使用copy_to 复制title 并将内容附加到该字段。
  • @RussCam 谢谢。成功了!!!

标签: c# elasticsearch nest kibana-4


【解决方案1】:

根据@RussCam 的评论,设置 index.query.default_field 将有助于进行默认字段搜索 要使用 Nest 客户端进行设置,请参阅以下链接 Set index.query.default_field using NEST Client c#

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-16
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多