0
votes

I am trying to do query like this:

Gym.search({
                    "query" : {
                        "multi_match": {
                            "fields": ["multi_field"],
                            "query": req.query.q,
                            "fuzziness": "AUTO"
                        }
                    }
                },
                function (err, results) {
                    if (err) {
                        return console.log(JSON.stringify(err, null, 4));
                    }
                    return console.log(JSON.stringify(results, null, 4));
                });

But it returns:

"status": 400, "displayName": "BadRequest", "message": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[PzLsLPHfTMu68AQ94_Af8g][gyms][0]: SearchParseException[[gyms][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][1]: SearchParseException[[gyms][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][2]: SearchParseException[[gyms][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][3]: SearchParseException[[gyms][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][4]: SearchParseException[[gyms][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }]"

It works when I use CURL... Anyone know how to fix it?

1

1 Answers

1
votes

Try like this:

 Gym.search({
                "multi_match": {
                    "fields": ["multi_field"],
                    "query": req.query.q,
                    "fuzziness": "AUTO"
                }
            },
            function (err, results) {
                if (err) {
                    return console.log(JSON.stringify(err, null, 4));
                }
                return console.log(JSON.stringify(results, null, 4));
            });