Wildcard Not Working as Expected


(Kevin M.) #1

Why does this query work as expected:

{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "query_string" : {
            "query" : "orgs.normalized: UBER"
        }
    }
}

But this one does not:

{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "query_string" : {
            "query" : "orgs.normalized: UBE*"
        }
    }
}

Do I have to do something special because of the widlcard (*) symbol? The field is set to NOT_ANALYZED, is that the problem? That is, I can't run wildcard queries against a NOT_ANALYZED field? Please advise. Thanks.

Kevin


(David Pilato) #2

Can you remove the space after the fieldname?


(Kevin M.) #3

@dadoonet I just tried removing the space after the field name and get the same result. The query executes with no errors, I just don't get any results and I know there are in fact matching documents. I also tried using lowercase even though our data is normalized to all uppercase before we push it into Elastic and that did not work either. Does this have something to do with the fact that the field is NOT_ANALYZED? Any addtional thoughts you may have on this would be appreciated. Thanks.

Kevin


(Kevin M.) #4

This issue is resolved and this query works, note the wildcard piece of the query:

{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "wildcard": {"orgs.normalized": "UBE*"}
    }
}

This also works:


{    
    "size": 100, 
    "fields": ["document", "orgs.normalized"],
    "query": {
        "query_string" : {
            "query" : "orgs.normalized: UBE*",
            "lowercase_expanded_terms": false
        }
    }
}
 

An excellent write-up of this issue can be found here:

Kevin


(system) #5

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