Elasticsearch query help


(Tim Dunphy) #1

Hi all,

I have an elastic search index called 'episodes' with info in there about TV episodes.

I am trying to return a record from the 'episodes' index and am unsuccessful:

#curl -XPOST "http://3.3.87.69:9200/episodes/_search" -d'
{
    "match" : {
         "title":"NBC Cancels Star Trek"
    }
}'

{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[vWsbh3nQRi-02ZhWWhwtyw][episodes][0]: RemoteTransportException[[ShowDB-Acceptance_3][inet[/3.3.87.71:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[episodes][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    \"match\" : {\n         \"title\":\"NBC Cancels Star Trek\"\n    }\n}]]]; nested: SearchParseException[[episodes][0]: from[-1],size[-1]: Parse Failure [No parser for element [match]]]; }{[Z_hQM2qVTx6ECbLAB9OKng][episodes][1]: SearchParseException[[episodes][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    \"match\" : {\n         \"title\":\"NBC Cancels Star Trek\"\n    }\n}]]]; nested: SearchParseException[[episodes][1]: from[-1],size[-1]: Parse Failure [No parser for element [match]]]; }{[4yrGlJ4ST2iwdDl1l3vbNQ][episodes][2]: RemoteTransportException[[ShowDB-Acceptance_2][inet[/3.3.87.70:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[episodes][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    \"match\" : {\n         \"title\":\"NBC Cancels Star Trek\"\n    }\n}]]]; nested: SearchParseException[[episodes][2]: from[-1],size[-1]: Parse Failure [No parser for element [match]]]; }{[4yrGlJ4ST2iwdDl1l3vbNQ][episodes][3]: RemoteTransportException[[ShowDB-Acceptance_2][inet[/3.3.87.70:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[episodes][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    \"match\" : {\n         \"title\":\"NBC Cancels Star Trek\"\n    }\n}]]]; nested: SearchParseException[[episodes][3]: from[-1],size[-1]: Parse Failure [No parser for element [match]]]; }{[Z_hQM2qVTx6ECbLAB9OKng][episodes][4]: SearchParseException[[episodes][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n    \"match\" : {\n         \"title\":\"NBC Cancels Star Trek\"\n    }\n}]]]; nested: SearchParseException[[episodes][4]: from[-1],size[-1]: Parse Failure [No parser for element [match]]]; }]","status":400}

And this is the info I am trying to retrieve with the ES query but am unable to:

"_source":{"id":4,"number":"0010","show_id":3,"title":"NBC Cancels Star Trek","air_date":"1977-07-04","season":"4","episode_type":"live","hosts":[{"id":7,"name":"Elliot Gould","distinguishing_info":null}],"musical_guests":[{"id":10,"name":"Sex Pistols","distinguishing_info":null}],"episode_versions":[{"id":4,"video_url":"http://www.pivotal.io","episode_id":4,"air_date":"1977-07-04","episode_version_type_id":3,"repeat_text":"some data for SNL entered by pivotal","parent_episode_version_id":null,"episode_version_type":{"id":3,"show_id":3,"name":"Air"},"segments":[]}]}
    },

Can someone please help me out on the syntax on how to retrieve this record from ES?

Thanks


(Dan Tuffery) #2

You need to wrap a query object around the match object.

#curl -XPOST "http://3.3.87.69:9200/episodes/_search" -d'
{
    "query":{
        "match" : {
            "title":"NBC Cancels Star Trek"
         }
     }
}'

(Tim Dunphy) #3

Ok! Got it. Thanks! Yeah that works.


(system) #4