1

I have trouble getting the facet in my index. Basically I want to get the details of particular facet say "Company" in a separate array

I tried many queries but it all get entire facet under facet array .How can I get only particular facet in a facet array

My index is https://gist.github.com/4015817

Please help me .I am badly stuck here

1 Answer 1

2

Considering how complex your data structure is, the simples way to extract this information might be using script fields:

curl "localhost:9200/index/doc/_search?pretty=true" -d '{
    "query" : {
        "match_all" : {

        }
    },
    "script_fields": {
        "entity_facets": {
            "script": "result=[];foreach(facet : _source.Categories.Types.Facets) {if(facet.entity==entity) result.add(facet);} result",
            "params": {
                "entity": "Country"
            }

        },
        "first_facet": {
            "script": "_source.Categories.Types.Facets[0]"    
        }

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

1 Comment

thanks alot imotov. You helped me from a great trouble. Thanks very much .

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.