Exists Query for Object type

Hi guys, I know that for execute a "exists" query in a nested type I could use a nested query.
But how about simple Object type?

I am doing this:

{
"from" : 0,
"size" : 10,
"query" : {
"bool" : {
"must" : [
{
"match_all" : {
}
},
{
"exists" : { "field" : "object_type_field" }
}
]
}
}
}

Hi,
Would a must match work? See here: https://www.elastic.co/guide/en/elasticsearch/guide/master/nested-query.html

No, because the field is not a nested type :frowning:

"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] nested object under path [item_availability_hours] is not of nested type"
}

here is the field:

{
    "properties": {
      "item_availability_hours": {
        "properties": {
          "FRIDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          },
          "MONDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          },
          "SATURDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          },
          "SUNDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          },
          "THURSDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          },
          "TUESDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          },
          "WEDNESDAY": {
            "type": "nested",
            "properties": {
              "end": {
                "type": "date",
                "format": "hour_minute_second"
              },
              "start": {
                "type": "date",
                "format": "hour_minute_second"
              }
            }
          }
        }
      }
    }

}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.