Can we use wildcard in the field_name or Can we apply condition in fields block inside query_string

Hi friends, I have the following questions related to the Elasticsearch:-

  1. I want to know Can we use the wildcard in the fields name in term block in the query, if not is there any alternate way to achieve this.like In the below query I want to achieve something like this.
    "must": [
                {
                  "term": {
                    "*_sold.Type": "Type XYZ"
                  }
                }
        ]
  }```
  1. How we can apply condition in "fields" in query_string block. e.g I have this part of query I want that if type of attribute is Type XYZ then only we need to search into this attribute.
{
          "query_string": {
            "query": "data",
            "type": "best_fields",
            "fields": [
              "date",
              "id_number",
              "type",
              "*__Sold.*"  // here I want that if "*_Sold.Type" == "Type XYZ" then only seach inside this attributes otherwise skip it.  
            ],
            "lenient": true,
            "default_operator": "AND",
            "boost": 3
          }

}

Here is the sample document.

    {
            "_index" : "_dev",
            "_type" : "_doc",
            "_id" : "data-2",
            "_score" : 1.0,
            "_source" : {
              "type" : "datas",
              "id_number" : 736762732784934,
              "date" : "2011-01-26",
              "Service_Sold" : [
                {
                  "Type" : "Type XYZ",
                  "Service_Name" : "Service XYZ"
                }
              ],
              "Product_Sold" : [
                {
                  "Type" : "Type ABC",
                  "Product_Name" : "Product ABC"
                }
              ]
              "Item_Sold" : [
                {
                  "Type" : "Type XYZ",
                  "Item_Name" : "Item XYZ"
                }
              ]
              ...
              50 other attributes
  }

Would appreciate any suggestions and help.

Note:- 7.10 version elastic-seach running queries on KIBANA. We can also upgrade our verison if required.

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