Minus sign in field name doesn't work in nested filter


(Petr Yanovich) #1

Imagine I have got a mapping

{
  "first-name": {
    "type": "string"
  },
  "profiles": {
    "type": "nested",
    "properties": {
      "first-name": {
        "type": "string"
      },
      "email": {
        "type": "string"
       }
    }
  }
}

And a query:

{
  "query": {
    "filtered": {
      "filter": {
        "nested": {
          "path": "profiles",
          "filter": {
            "term": {
              "first-name": "Nick"
            }
          }
        }
      }
    }
  }
}

This query doesn't work. It works for email field, but not for "first-name".
Also querying root "first-name" field works fine, the problem happens only while I am trying to use nested filter.

Thank you.


(Petr Yanovich) #2

Ok. The problem was not related to minus sign. I should use full qualified names in nested filter

{
  "query": {
    "filtered": {
      "filter": {
        "nested": {
          "path": "profiles",
          "filter": {
            "term": {
              "profiles.first-name": "Nick"
            }
          }
        }
      }
    }
  }
}

(system) #3