0

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"
              }
            }
          }
}
2
  • Can you post mapping for the index and ES version you are using. Query is working fine for me. Commented Jul 10, 2018 at 12:05
  • I added the mapping and the version in my initial question Commented Jul 10, 2018 at 12:20

2 Answers 2

1

try this

or this should work

{
  "query": {
    "nested": {
      "path": "product",
      "query": {
        "match": {
          "proucts.size" : "25"
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Haven't tried. Little busy right now. Will happy to hear your feedback thanks.
Nope - no results
0

This one works:

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

3 Comments

Yeah also corrected my answer. Somehow missed to add "products" key name.
Thank you. But why is the simple one failing?
Because of mapping. Mapping of products is defined as nested mapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.