2

I have an elasticsearch index with numeric category ids like this:

{
  "id": "50958",
  "name": "product name",
  "description": "product description",
  "upc": "00302590602108",
  "**categories**": [
    "26",
    "39"
  ],
  "price": "15.95"
}

I want to be able to pass an array of category ids (a parent id with all of it's children, for example) and return only results that match one of those categories. I have been trying to get it to work with a term query, but no luck yet.

Also, as a new user of elasticsearch, I am wondering if I should use a filter/facet for this...

ANSWERED! I ended up using a terms query (as opposed to term). I'm still interested in knowing if there would be a benefit to using a filter or facet.

1
  • Can you please help me with this question? Thanks Commented Jul 15, 2014 at 7:00

1 Answer 1

0

As you already discovered, a termQuery would work. I would suggest a termFilter though, since filters are faster, and cache-able.

Facets won't limit result, but they are excellent tools. They count hits within your total results of specific terms, and be used for faceted navigation.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you please help me with this question? Thanks
@AbhishekSimon yep just responded. I can include more detail in a few hours, but I linked to the type you need to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.