Field names with dot notation in ES Node.js client

Hi, I'm trying to write a field with dot notation in the body of the Search API in Node.js Client but it doesn't work.

The mapping is :

"my_field": {
    "type":"text",
    "fields": {
      "keyword": {
        "type": "keyword"
      } 
    }
  }

I tried :

query: {
    bool: {
      must: {
        term: my_field.keyword: my_value
      }
    }
}
query: {
    bool: {
      must: {
        term: "my_field.keyword": my_value
      }
    }
}
query: {
    bool: {
      must: {
        term: {
          my_field: {
            keyword: my_value
          }
        }
      }
    }
}
query: {
    bool: {
      must: {
        term: {
          my_field: {
              fields: {
                  keyword: my_value
              }
          }
        }
      }
    }
}

It's throws a parsing error from Elasticsearch.

Thank you in advance for your help :slight_smile:

After several tests on Node.js client, it works using JSON Object Notation for entirely body (all field names and values double quoted) instead of a common object notation. In the documentation it's mentioned :

body : object - The search definition using the Query DSL

and the example show a common object notation but not a JSON Object notation in the body field. I suppose that works because the requests need to be send to elasticsearch with application/json content-type and the parser work to do that.

"query": {
    "bool": {
      "must": {
        "term": "my_field.keyword": "my_value"
      }
    }
}

Could someone confirm that it's a correct way please ?

Thank you in advance.

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