简体   繁体   中英

ElasticSearch span search over multiple Index over all fields

I am working on a User Interface (HTML + JavaScript) which queries ElasticSearch 1.4 Right now the search is spanned over multiple indexes using the following URL: http://localhost:9200/_all/_search But in order to query all the fields I have to send the following JSON in the POST request: Formatted JSON Data

{  
   "query":{  
      "multi_match":{  
         "query":"monitor",
         "type":"most_fields",
         "fields":[  
            "First Name",
            "Last Name",
            "ProductName",
            "Organization",
            "Description"
         ]
      }
   },
   "highlight":{  
      "fields":{  
         "*":{  

         }
      }
   }
}

The problem arise because I don't want to specify the search fields . I want to ask to ElasticSearch to search on all the available fields of all documents. Is this possible?

Personally would not recommended running a query against all indexes and fields without explicitly specifying the list of indices and fields since this could adversely impact the cluster performance.

However in case you need to you could try using query_string query:

Example:

  "query": {
        "query_string": {
           "fields": ["*"],
           "query": "monitor",
           "lenient":true,
           "use_dis_max" : false           
        }
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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