Hi guys,

I am not very familiar with aggregations and filtering in ElasticSearch, so 
I hope you can help me with my problem.

*Scenario:*

A user visits our website and is searching for a specific product. He 
clicks to the search field and types a specifc string. Then hit clicks on 
"Search" and gets a list of search results based on his query.

The user wants to filter the products by a specific feature. He selects 
"1024x768" as screen resolution and gets a list of products with the screen 
resolution "1024x768". Now he wants to get only products that have the 
screen resolution "1024x768" and "VGA cable".

This is quite comparable to the search and filtering mechanism you can find 
at amazon.com.

*Problem:*

After some filtering steps, the products are quite similiar and share most 
of the features BUT some features aren't available for all of these 
products.

Is there a way to filter out all features that are available for all 
products to get only a list of features that are available for some of 
these products to be able to decrease the amount of products in the next 
step?

*Example document:*

{   "segments": [     {
      "id": 1,
      "name": "Segment One",
      "features": [
        {
          "id": 1,
          "name": "Feature One"
        },
        {
          "id": 2,
          "name": "Feature Two"
        }
      ]
    },
    {
      "id": 2,
      "name": "Segment Two",
      "features": [
        {
          "id": 3,
          "name": "Feature Three"
        },         {
          "id": 4,
          "name": "Feature Four"
        }
      ]
    }
  ] }

*Current example query:*

{
  "query": {
    "filtered": {
      "query": {
        "match": "Monitor"
      },
      "filter": {
        "and": [
          {
            "term": {
              "segments.features.id": 3
            }
          }
        ]
      }
    }
  },
  "aggs": {
    "features": {
      "terms": {
        "lang": "groovy",
        "script": "strs = new ArrayList(); for (s in 
doc['segments.features.id']) { strs.add(s.toString()); }; return strs;",
        "exclude": "3"
      }
    }
  }
}

Regards,
Jan

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/32ebd1f4-7e58-4261-9b8d-b6ceeddfdfc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to