简体   繁体   English

Elasticsearch 通用搜索查询

[英]Elasticsearch universal search query

I have a string "Jhon Abraham 18".我有一个字符串“Jhon Abraham 18”。 I want to create search query that will search by divided by spaces words from the string in an index.我想创建搜索查询,该查询将按索引中字符串中的空格除词进行搜索。 This search have to be set to all fields of the index and you don't know what meaning have to be mapped(set) to a field.此搜索必须设置为索引的所有字段,您不知道必须映射(设置)到某个字段的含义。 So, I have a document:所以,我有一个文件:

{
  "_index": "recipient",
  "_type": "recipient",
  "_id": "37a15258d9",
  "_version": 1,
  "_score": 1,
  "_source": {
    "name": "Jhon ",
    "surname": "Abraham",
    "age": "18 ",
}

and I don't know to what fields of index meanings Jhon, Abraham and 18 correspond.我不知道 Jhon、Abraham 和 18 对应于索引含义的哪些字段。 I just have a string and by this string I want to search in all fields of the index documents.我只有一个字符串,我想通过这个字符串在索引文档的所有字段中进行搜索。 I can divide it by separete words by spaces but I don't know exact mapping fields for search.我可以用空格分隔单独的单词,但我不知道用于搜索的确切映射字段。 Also, I want to do it at Java.另外,我想在 Java 中做到这一点。 I'll be appreciate for help.我将不胜感激。

I think you should use query_string in elasticsearch.我认为你应该在 elasticsearch 中使用 query_string。

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

This will solve your problem.这将解决您的问题。

You can use multi match query, writing all fields or wildcards.您可以使用多匹配查询,写入所有字段或通配符。

Multi Match Query 多匹配查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM