elasticsearchelassandra

Elasticsearch: Simple query not matching fields


I want to query an elastic index with the simple query syntax.

My query:

{
  "query": {
    "simple_query_string" : {
        "query": "25",
        "fields" : ["product.size"]
    }
  }
}

is returning no results, altough there is an entry with the matching value in the field:

{
  "took" : 869,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "hits" : {
    "total" : 97241,
    "max_score" : 1.8576174,
    "hits" : [
      {
        "_index" : "deviceinformation",
        "_type" : "deviceinfo",
        "_id" : "314043",
        "_score" : 1.8576174,
        "_source" : {
          "baseinfo" : {
            "material_no" : "314043",
            "dimensional_drawing_nr" : "118600"
          },
          "product" : {
            "size" : "25",
            "range" : "I",
            "type" : "MAC"
          }
      }]
}

What am I doing wrong?

EDIT: I am using Elassandra 5.5.0.18 = Elasticsearch 5.5.0 + Cassandra 3.11.2 Excerpt from the mapping:

{
  "deviceinformation" : {
    "mappings" : {
      "deviceinfo" : {
          "product" : {
            "type" : "nested",
            "cql_collection" : "singleton",
            "cql_udt_name" : "product",
            "properties" : {
              "base_size" : {
                "type" : "keyword",
                "cql_collection" : "singleton"
              },
              "pressure_stage" : {
                "type" : "keyword",
                "cql_collection" : "singleton"
              },
              "range" : {
                "type" : "keyword",
                "cql_collection" : "singleton"
              },
              "size" : {
                "type" : "keyword",
                "cql_collection" : "singleton"
              },
              "type" : {
                "type" : "keyword",
                "cql_collection" : "singleton"
              }
            }
          }
}

Solution

  • try this

    or this should work

    {
      "query": {
        "nested": {
          "path": "product",
          "query": {
            "match": {
              "proucts.size" : "25"
            }
          }
        }
      }
    }