2

Here is my query

POST indexName/test/_search
{
  "fields" : ["Col1"],
  "query":{
                        "filtered":{

                        "query":{


                        "wildcard": {

                            "Col1": {

                                  "value": "*zxc*"
                               }
                            }

                          },
                        "filter":
                {
                  "term": { 

                    "Col2": "val" 

                  }
                }
                    }

            }
}

so i want to do a wildcard on Col1 for the value *zxc* and i want only those values where Col2 is val this returns 0 hits. is there anything wrong with my syntax?

The wildcard query works independently if i remove the filter.

Edit

this works

POST indexName/test/_search
{
  "fields" : ["Col1"],
  "query":{
                        "filtered":{


                        "filter":
                {
                  "term": { 

                    "Col2": "val" 

                  }
                }
                    }

            }
}

sample document returned

{
        "_index": "indexName",
        "_type": "test",
        "_id": "oainfubgvwurebetrnjt",
        "_score": 1,
        "fields": {
          "Col1": [
            "uyiwebvybg iuowenbgubnrwev  uirbgvuire3bv  vuirbg"
          ]
        }
      }

and so does this

POST indexName/test/_search
{
  "fields" : ["Col1"],
  "query":{
                        "wildcard": {

                            "Col1": {

                                  "value": "*zxc*"
                               }
                            }

            }
}

sample document returned

{
        "_index": "indexName",
        "_type": "test",
        "_id": "aofnhuiwegbnweu",
        "_score": 1,
        "fields": {
          "Col1": [
            "idasihid huwbgbuiwb iuohfuweb zxc oifjhwgbu"
          ]
        }
      }

so both of these queries work independently. How do i combine them?

Edit

here is what a typical response looks like with both fields included

{ "_index": "indexName", "_type": "test", "_id": "aofnhuiwegbnweu", "_score": 1, "fields": { "Col1": [ "idasihid huwbgbuiwb iuohfuweb zxc oifjhwgbu" ],

        "Col2": [
                "asd"
              ]
        }
      }

for query

POST indexName/test/_search
    {
      "fields" : ["Col1","Col2"],
      "query":{
                            "wildcard": {

                                "Col1": {

                                      "value": "*zxc*"
                                   }
                                }

                }
    }

similar results for the other one

AbtPst
  • 7,778
  • 17
  • 91
  • 172
  • How about if you remove the wildcard query. Does the document you are looking for get returned with just the filter on Col2? – BrookeB Feb 23 '16 at 19:55
  • yes, please see the edit. both queries work independently – AbtPst Feb 23 '16 at 20:03
  • Odd...I can't see anything wrong with the query. Can you provide a sample document that is being returned successfully with both your independent queries? – BrookeB Feb 23 '16 at 20:05
  • i added the sample documents. please see the edit. – AbtPst Feb 23 '16 at 20:11
  • the sample document does not show values for `Col2` – keety Feb 23 '16 at 20:54
  • 1
    Since you have `"fields" : ["Col1"],`, we don't get to see the value in `Col2`. Just for debugging, can you include `Col2` in the response? Thanks. – BrookeB Feb 23 '16 at 21:03
  • i will add that, but i dont need Col2 in results. it is just another string – AbtPst Feb 24 '16 at 03:39
  • 1
    Document returned when you run `"Col2": "val" ` query is different from the one which is returned when you run `"value": "*zxc*"` query. – Richa Feb 24 '16 at 06:20
  • yes, more often than not it will be, but i am looking for the set where the results of the two queries intersect – AbtPst Feb 24 '16 at 13:23
  • please see the edit. i have added a sample result with `Col2` included. i dont know how that adds anything – AbtPst Feb 24 '16 at 14:18
  • Has anyone been able to run the wildcard query with filter? I just want to know that the concept works. – AbtPst Feb 25 '16 at 12:32

0 Answers0