0

I am using a filtered query with sort. When i run the query using the browser plugin, it runs fine. But when i use java client that ships with ElasticSearch, i get error

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], all shards failed; shardFailures

Here is the query thats being run

{
    "from": 0,
    "size": 50,
    "query": {
        "filtered": {
            "query": {
                "bool": {
                    "must": {
                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "_all": {
                                            "query": "Happy Pharrel Williams",
                                            "type": "boolean"
                                        }
                                    }
                                },
                                {
                                    "flt": {
                                        "fields": [
                                            "name",
                                            "artists",
                                            "genre",
                                            "albumName"
                                        ],
                                        "like_text": "Happy Pharrel Williams"
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "filter": {
                "bool": {
                    "must": {
                        "or": {
                            "filters": [
                                {
                                    "range": {
                                        "releaseInfo.us": {
                                            "from": null,
                                            "to": "2015-07-22T23:16:12.852Z",
                                            "include_lower": true,
                                            "include_upper": true
                                        }
                                    }
                                },
                                {
                                    "and": {
                                        "filters": [
                                            {
                                                "missing": {
                                                    "field": "releaseInfo.us"
                                                }
                                            },
                                            {
                                                "range": {
                                                    "releaseInfo.WW": {
                                                        "from": null,
                                                        "to": "2015-07-22T23:16:12.851Z",
                                                        "include_lower": true,
                                                        "include_upper": true
                                                    }
                                                }
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    },
    "fields": [],
    "sort": [
        {
            "popularity.US": {
                "order": "asc",
                "missing": 999
            }
        },
        {
            "_score": {}
        }
    ] }

I understand that the error sounds like the field i am sorting on is missing in some of the indices. But i have provided the "missing" option in my sort and the query runs just fine when i run from ES browser head plugin.

Do you see anything wrong with the query structure or something else with Java Client ?

Val
  • 207,596
  • 13
  • 358
  • 360
snegi
  • 636
  • 1
  • 6
  • 22
  • I was getting the exception because i was using a sort on a field that didn't exist in a certain number of indexed documents. I re-indexed all the documents and it worked. – snegi Jul 29 '15 at 21:38

1 Answers1

0

I was getting the exception because i was using a sort on a field that didn't exist in a certain number of indexed documents. I re-indexed all the documents and it worked.

snegi
  • 636
  • 1
  • 6
  • 22