How to query for different fields in elasticserch?

elasticsearch match multiple fields with different values
elasticsearch match multiple values
elasticsearch multiple queries
elasticsearch match query example
elasticsearch bool query
elasticsearch query url
elasticsearch term query
elasticsearch multi field

I want to query elasticsearch for one or two key:value pair such as:


This query takes only the unique_id into consideration. If I change the Date to any invalid value, still it gives me all values based on the Unique_id.

Any idea how to make an AND condition with both the queries? It should consider both queries and provide result accordingly? Please advice. Thanks.

According to documentation, it should work


That said, you can create your query as below:


Note : %2B is decoded as '+' whereas '+' is decoded as ' '

Multi-Field Search Just Got Better, Elasticsearch provides the multi_match query, which makes multi-field search How you search across multiple fields depends on how your data is indexed  The query string is also analyzed by the standard analyzer for the text field, and by the english analyzer for the text.english field. The stemmed field allows a query for foxes to also match the document containing just fox. This allows us to match as many documents as possible.

Try this.

GET /index/type/_search
  "query": {
    "match": {"Date":"2015-09-17 03:45:00-04"}
  "filter" : {
    "and" : [
                        "match": {"unique_id" : "6324"}

Reference link -

Search on multiple fields with Elasticsearch, You need to pick the right query for the job, which can be hard in the beginning. You can definitely use a bool query to combine all sorts of  Elasticsearch supports a large number of queries. A query starts with a query key word and then has conditions and filters inside in the form of JSON object. The different types of queries have been described below. Match All Query. This is the most basic query; it returns all the content and with the score of 1.0 for every object.

You can choose this query also ,(easy way)

GET   myindex/mytype/_search
"query": {
  "bool" : {
     "must" :[ 
        "term" : { "unique_id" : "6324"}
        "term" : { "Date":"2015-09-17 03:45:00-04"}

23 Useful Elasticsearch Example Queries, To illustrate the different query types in Elasticsearch, we will be searching shorthand way of running the same query against multiple fields. Basic Match Query. There are two ways of executing a basic full-text (match) query: using the Search Lite API, which expects all the search parameters to be passed in as part of the URL, or using the full JSON request body which allows you use the full Elasticsearch DSL.

Elasticsearch Query: A Thorough Guide to Lucene Query Syntax , This tutorial covers Elasticsearch querying basics and Lucene. You specify the field, type a colon, then a space, then the string in quotation marks or You can use the * character for multiple character wildcards or the ? character for single  The default field for query terms if no prefix field is specified. Defaults to the index.query.default_field index settings, which in turn defaults to * . * extracts all fields in the mapping that are eligible to term queries and filters the metadata fields. All extracted fields are then combined to build a query when no prefix field is provided.

How to Query with Multiple Criteria in Elasticsearch, The fields go across from left to right, starting with the header columns for “id” through “department.” id, name, price, quantity, department. 1, Multi-  The first query that we provided looks for documents where the age field is between 30 and 40. The second query does a wildcard search on the surname field, looking for values that start with “K.” The query contained three different clauses, so Elasticsearch will only return documents that match the criteria in all of them.

Using Query String Queries in Elasticsearch, The _all field is a special field that is constructed by concatenating the values of all the other fields in your document so it's got all the terms found  Hi, Can i query across 2 indexes with just 2 common fields and get other fields in the results ? example : Index 1 has fields : A, B, C, D Index 2 has fields : A,B,E