logo
down
shadow

Elasticsearch match nested field against array of values


Elasticsearch match nested field against array of values

By : will_bowman
Date : November 22 2020, 02:59 PM
seems to work fine I think you would need to change your mappings for your nested types for this - the terms query only works on not_analyzed fields. If you update your mapping to something like:
code :
elasticsearch!({
    prefix_name: false,
    index_name: 'documents',
    index_options: {
    mappings: {
        document: {
            properties: {
                procuring_entity: {
                    type: 'nested',
                    properties: {
                        country: {
                            'type': 'string',
                            'index': 'not_analyzed'
                        }
                    }
                },
                awards: {
                    type: 'nested'
                }
            }
        }
    }
    },
    wrapper: :load
})


Share : facebook icon twitter icon
Search a nested field for multiple values on the same field with elasticsearch

Search a nested field for multiple values on the same field with elasticsearch


By : sanjay
Date : March 29 2020, 07:55 AM
like below fixes the issue I'm trying to query a nested properties with multiple values. , It just needs a bit change:
code :
{
  "query": {
    "bool": {
        "must": [
           {
               "nested": {
                  "path":"students",
                  "query": {
                    "bool": {
                      "must": [
                        {"match": {"name": "john"}}
                      ]
                    }
                  }
                }
           },
           {
               "nested": {
                  "path":"students",
                  "query": {
                    "bool": {
                      "must": [
                        {"match": {"name": "jack"}}
                      ]
                    }
                  }
                }
           }
        ]
    }
  }
}
curl -XPUT 'http://localhost:9200/testing_nested_query/class/1' -d '{
      "title": "class1",
      "students": [{"name": "john", "age": 4},{"name": "jack", "age": 1},{"name": "jim", "age": 9}]
    }'

curl -XPUT 'http://localhost:9200/testing_nested_query/class/2' -d '{
      "title": "class1",
      "students": [{"name": "john", "age": 5},{"name": "jack", "age": 4},{"name": "jim", "age": 9}]
    }'
{
  "query": {
       "nested": {
          "path":"students",
          "query": {
            "bool": {
              "must": [
                {"match": {"name": "john"}},
                {"match": {"age": 4}}
              ]
            }
          }
        }
  }
}
ElasticSearch: Getting all values for nested field

ElasticSearch: Getting all values for nested field


By : Elio Medina
Date : March 29 2020, 07:55 AM
I wish this help you You have to first declare a mappings for your index with user as nested field
code :
PUT my_index3
{
  "mappings": {
    "my_type": {
      "properties": {
        "user": {
          "type": "nested",
          "properties": {
            "firstname":{
              "type":"keyword"
            }
          }
        }
      }
    }
  }
}


PUT my_index3/my_type/1
{
  "group" : "fans",
  "user" : [
    {
      "firstname" : "John",
      "lastname" :  "Smith"
    },
    {
      "firstname" : "Alice",
      "lastname" :  "White"
    },
    {
      "lastname": "Muller" 
    }
  ]
}
POST my_index3/_search
{
  "size": 0,
  "aggs": {
    "nested_user": {
      "nested": {
        "path": "user"
      },
      "aggs": {
        "firstname": {
          "terms": {
            "field": "user.firstname",
            "size": 10
          }
        }
      }
    }
  }
}
Elasticsearch: How to get an exact match in a nested field

Elasticsearch: How to get an exact match in a nested field


By : H. Attar
Date : March 29 2020, 07:55 AM
this one helps. The mapping contains nested fields which shouldn't be analyzed (not sure if the 'not_analyzed' value is accurate). Is it possible to do an exact match on a nested field? In the query below the "metadata.value": "2014.NWJSD.47" still gets analyzed. Elasticsearch breaks up the string into several terms ("2014", "NWJSD", "47"). I tried to use "term" instead of "match" but this didn't return any result. , Try to use keyword instead of text in your mapping like:
code :
{
   "mappings": {
      "your_type_name": {
         "properties": {
            "metadata" : {
               "type" : "nested",
               "properties" : {
                  "name" : {
                     "type" : "keyword"
                   },
                  "value" : {
                     "type" :"keyword"
                  }
               }
             }
           }
        }
     }
  }
 {
    "query": {
       "bool": {
          "must": [
             {
                "nested": {
                   "path": "metadata",
                   "query": {
                      "bool": {
                        "must": [
                           {
                              "term": {
                                 "metadata.name": "number"
                               }
                            },
                            {
                               "term": {
                                  "metadata.value": "2014.NWJSD.47"
                               }
                            }
                         ]
                      }
                   }
                }
             }
          ]
       }
    }
 }
Match all values in a nested array using elasticsearch

Match all values in a nested array using elasticsearch


By : QUANGPHAT ĐINH
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I am trying to use elasticsearch to match all values in a nested array. For eg. my search array is ["1","2","3","4","5","6","7","8","9"] and my document contains an array of arrays like , You can get away with a simple Groovy script like this one:
elasticsearch how to include many values for the same field in the match phrase

elasticsearch how to include many values for the same field in the match phrase


By : micode
Date : March 29 2020, 07:55 AM
I wish this helpful for you The error comes from the parser, you must specified with an "OR" when passing multiple needles.
to fix your case you must replace
Related Posts Related Posts :
  • How do we bucket aggregate only on the matched prefix on Elasticsearch?
  • Writing queries in Kibana search bar
  • Request timedout during delete/create on elasticsearch while snapshot is being taken
  • How to really reindex data in elasticsearch
  • Issue in reading log file that contains date in it's name
  • Nesting relationship with ElasticSearch
  • Combining Attribute / Fluent Mapping for Copy_To with Nest
  • Elasticsearch term suggester does not return results on exact match
  • Does sense only work in Kibana?
  • ElasticSearch: Partial/Exact Scoring with edge_ngram & fuzziness
  • Elasticsearch cluster data migration to new cluster
  • How do we delete only certain events in an index in elasticsearch?
  • How to create multiple indexes in logstash.conf file?
  • Why is that after deleting an index in logstash, Kibana still displays it?
  • wildcard queries with multiple fields in ES?
  • Elasticsearch mapping not working
  • Elastic Search fulltext search query and filters
  • Why doesn't elasticsearch allow changes to an indexed data?
  • Create a new index per day for Elasticsearch in Logstash configuration
  • Elasticsearch: get up to date size of an index
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co