Bitmap search not working?

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 2.17.0

Describe the issue:

I’ve just tried the example code at Terms - OpenSearch Documentation on a local, docker-compose cluster. But for the final query (direct query with bitmap encoded to base64) I get:

      {
        "type": "parsing_exception",
        "reason": "[terms] query does not support [product_id]",
        "line": 4,
        "col": 21
      }

When I try the query with a reference to customers (as documented on the page linked above), I get 0 results.

Do I need to enable something to get the bitmap functionality?

Configuration:
Defaults for docker-compose.

Relevant Logs or Screenshots:

I’ve confirmed this instruction has two points to be fixed.

  • product_id field should be integer
  • terms requires array value against specified key

Here is fixed instruction. Please check results on your side.

PUT /products
{
  "mappings": {
    "properties": {
      "product_id": { "type": "integer" }
    }
  }
}
PUT products/_doc/1
{
  "name": "Product 1",
  "product_id" : 111
}
PUT products/_doc/2
{
  "name": "Product 2",
  "product_id" : 222
}
PUT products/_doc/3
{
  "name": "Product 3",
  "product_id" : 333
}

POST /products/_search
{
  "query": {
    "terms": {
      "product_id": [
        "111",
        "222",
        "333"
      ]
    }
  },
  "profile": "true"
}

PUT /customers
{
  "mappings": {
    "properties": {
      "customer_filter": {
        "type": "binary",
        "store": true
      }
    }
  }
}

PUT customers/_doc/customer123
{
  "customer_filter": "OjAAAAEAAAAAAAIAEAAAAG8A3gBNAQ==" 
}

POST /products/_search
{
  "query": {
    "terms": {
      "product_id": {
        "index": "customers",
        "id": "customer123",
        "path": "customer_filter",
        "store": true
      },
      "value_type": "bitmap"      
    }
  },
  "profile": "true"
}

POST /products/_search
{
  "query": {
    "terms": {
      "product_id": [
        "OjAAAAEAAAAAAAIAEAAAAG8A3gBNAQ=="
      ],
      "value_type": "bitmap"      
    }
  },
  "profile": "true"
}

I’ve submit new issue for further investigation or document fix.

Thx a lot @tkykenmto! Your example works indeed. And I’ve confirmed it on my own test data too. Both changes are required: the field needs to be mapped as an integer and the terms query needs to get an array value.