John Fadria
John Fadria

Reputation: 1945

Couchbase - Elasticsearch search issue

I've followed the Couchbase - ElasticSearch tutorial integration and I'm testing it with the beer-sample bucket.

I have an issue.

I can do a query like:

{
    "query": {
        "match": {
            "doc.name": "IPA"
        }
    }
}

but if I search like that:

{
    "query": {
        "filtered": {
            "query": {
                "match_all": { }
            },
            "filter": {
                "term": { "doc.name": "IPA" }
            }
        }
    }
}

I don't obtain any result.

With other string field I don't have problems, for example, the "type" : "beer"

{
    "query": {
        "match": {
            "doc.type": "beer"
        }
    }
}

{
    "query": {
        "filtered": {
            "query": {
                "match_all": { }
            },
            "filter": {
                "term": { "doc.name": "beer" }
            }
        }
    }
}

I don't know why.

Thanks in advance

Upvotes: 1

Views: 144

Answers (1)

DeH
DeH

Reputation: 571

It is because of your analyzer. For strings, the default analyzer lowercases the imput. So, IPA is indexed as ipa.

A term filter does not analyze your imput, and thus, you search for IPA and in your index, you have ipa --> IPA != ipa , and thus, the document do not match.

The match query, on the other end, analyzes your input using the analyzer that was set for the field, thus, your input is lowercased and you search for ipa.

I hope it makes sense.

Upvotes: 1

Related Questions