1
votes
var searchParams = {
        index: 'offers',
        body: {
            query: {
                function_score: {
                    query: {match_all: {}},
                    boost: '5',
                    functions: [
                        {
                            filter: {
                                geo_distance: {
                                    distance: radius,
                                    location: {
                                        lat: latitude,
                                        lon: longitude
                                    }
                                }
                            },
                            random_score: {},
                            weight: 23
                        }
                    ],
                    max_boost: 23,
                    score_mode: 'max',
                    boost_mode: 'multiply',
                    min_score: 23
                }
            }
        },
        filter_path: 'hits.hits._source',
        from: from,
        size: size,
        sort: ["_score"],
        pretty: 'true'

    };

This give me error:

{ Error: [parsing_exception] Unknown key for a START_OBJECT in [function_score]., with { line=1 & col=19 } at respond (/user_code/node_modules/elasticsearch/src/lib/transport.js:307:15) at checkRespForFailure (/user_code/node_modules/elasticsearch/src/lib/transport.js:266:7) at HttpConnector. (/user_code/node_modules/elasticsearch/src/lib/connectors/http.js:159:7) at IncomingMessage.bound (/user_code/node_modules/elasticsearch/node_modules/lodash/dist/lodash.js:729:21) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9) status: 400, displayName: 'BadRequest', message: '[parsing_exception] Unknown key for a START_OBJECT in [function_score]., with { line=1 & col=19 }', path: '/offers/_search', query: { filter_path: 'hits.hits._source', from: 0, size: 2, sort: '_score', pretty: 'true' }, body: { error: { root_cause: [Object], type: 'parsing_exception', reason: 'Unknown key for a START_OBJECT in [function_score].', line: 1, col: 19 }, status: 400 }, statusCode: 400, response: '{\n "error" : {\n "root_cause" : [\n {\n "type" : "parsing_exception",\n "reason" : "Unknown key for a START_OBJECT in [function_score].",\n "line" : 1,\n "col" : 19\n }\n ],\n "type" : "parsing_exception",\n "reason" : "Unknown key for a START_OBJECT in [function_score].",\n "line" : 1,\n "col" : 19\n },\n "status" : 400\n}\n', toString: [Function], toJSON: [Function] }

how to solve it?

Is there any wrapper for elastic search in node.js?

1

1 Answers

-1
votes

Search this package: "elasticsearch" into npm