Find docs with dynamic attribute

I have the following sample docs

  • “c” is a dynamic blob but has the same syntax c.XXX.YYYY.ZZZ = a value.
    For this example I will use the same.

{
“name”: “1”,
“type”: “t”,
“c”: {
“127b4b25”: {
“value”: {
“car”: “Tesla M3”
}
}
}
}

{
  "name": "2",
  "type": "t",
  "c": {
    "127b4b25": {
      "value": {
        "car": "Tesla M3"
      }
    }
  }
}
{
  "name": "3",
  "cfield:127b4b25-0b5c-4007-b23b-f966ed55fe66:value:sos": "Resident Occupied",
  "c": {
    "127b4b25": {
      "value": {
        "car": "BMW M3"
      }
    }
  },
  "type": "t"
}

Index FTS
{
“type”: “fulltext-index”,
“name”: “s_test”,
“uuid”: “3caa432c34600289”,
“sourceType”: “couchbase”,
“sourceName”: “shadow_test”,
“sourceUUID”: “bad5b1b97307900a7debe69295d8d391”,
“planParams”: {
“maxPartitionsPerPIndex”: 171,
“indexPartitions”: 6
},
“params”: {
“doc_config”: {
“docid_prefix_delim”: “”,
“docid_regexp”: “”,
“mode”: “type_field”,
“type_field”: “t”
},
“mapping”: {
“analysis”: {
“analyzers”: {
“test”: {
“tokenizer”: “single”,
“type”: “custom”
}
}
},
“default_analyzer”: “standard”,
“default_datetime_parser”: “dateTimeOptional”,
“default_field”: “_all”,
“default_mapping”: {
“dynamic”: false,
“enabled”: true,
“properties”: {
“c”: {
“dynamic”: true,
“enabled”: true
},
“name”: {
“dynamic”: false,
“enabled”: true,
“fields”: [
{
“analyzer”: “keyword”,
“index”: true,
“name”: “name”,
“type”: “text”
}
]
}
}
},
“default_type”: “_default”,
“docvalues_dynamic”: true,
“index_dynamic”: true,
“store_dynamic”: false,
“type_field”: “_type”
},
“store”: {
“indexType”: “scorch”
}
},
“sourceParams”: {}
}

Sample Query:

{
“from”: 0,
“explain”:false,
“ctl”: {
“timeout”: 75000
},
“size”: 1000,
“query”: {
“conjuncts”: [
{
“field”: “c.127b4b25.value.car”,
“match”: “Tesla M3”
}
]
}
}

Issue: When I run the query I always get 3 docs vs 2. How do I ONLY get 2 docs?

@dipen_patel ,

The problem here is that you are using a match query for a multi-word/token query. And the conjunct isn’t serving any purpose here.
You could try a direct match phrase query for searching the phrases.
eg:

curl -XPOST -H "Content-Type: application/json" -u Administrator:asdasd http://server:port/api/index/<indexName>/query -d '{
  "query": {
    "match_phrase": "Tesla M3",
    "field": "c.127b4b25.value.car"
  }
}'
1 Like