Giter Site home page Giter Site logo

sudo-suhas / elastic-builder Goto Github PK

View Code? Open in Web Editor NEW
500.0 500.0 74.0 5.18 MB

A Node.js implementation of the elasticsearch Query DSL :construction_worker:

Home Page: https://elastic-builder.js.org

License: MIT License

JavaScript 99.69% TypeScript 0.24% Shell 0.07%
elasticsearch elasticsearch-query-dsl javascript nodejs query-builder

elastic-builder's People

Contributors

0xflotus avatar arnaud-cortisse avatar atreids avatar austince avatar bill-mcgrory avatar dependabot[bot] avatar diegotham avatar dimatill avatar exoego avatar florian-lackner365 avatar greenkeeper[bot] avatar greenkeeperio-bot avatar i-like-robots avatar ilarionhalushka avatar josh-degraw avatar juntezhang avatar kehers avatar kennylindahl avatar lostpebble avatar ministrudels avatar myashchenko avatar ochan12 avatar rccoe avatar robdasilva avatar ruicsh avatar sandeep952 avatar sudo-suhas avatar tengis avatar trevorr avatar xballoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elastic-builder's Issues

Create a scroll query

I wish to build this query-

GET index/_search?scroll=1m
{
    "slice": {
        "id": 0, 
        "max": 10
    },
    "query": {
        "match" : {
            "name" : "tommy"
        }
    }
}

I was able to do the query but not the slice

builder.requestBodySearch().query(builder.matchQuery("name", name));

composite aggregations

is there a possiblity to build composite aggregations, if not is there a possibility to append available json as an input to a query or an aggregate

termsQuery throws error when checking type of terms in REPL

node version: v8.11.3
esb version: 2.2.2

When using the termsQuery it incorrectly checks the terms type.

In the REPL:

esb.termsQuery('user', ['kimchy', 'elasticsearch'])
[ 'kimchy', 'elasticsearch' ] is of the type object
TypeError: Argument must be an instance of Array
    at checkType (/home/austin/Workspace/node_modules/elastic-builder/lib/core/util.js:34:15)
    at TermsQuery.values (/home/austin/Workspace/node_modules/elastic-builder/lib/queries/term-level-queries/terms-query.js:135:13)
    at new TermsQuery (/home/austin/Workspace/node_modules/elastic-builder/lib/queries/term-level-queries/terms-query.js:75:46)
    at Object.termsQuery (/home/austin/Workspace/node_modules/elastic-builder/lib/core/util.js:52:16)

Sort/ script: Instance Member

Hi! I found out some problem using esb.sort()

According to the document (https://elastic-builder.js.org/docs/#sort), it says that esb.sort needs field as essential and order as optional. It works fine for specific field. But there is a problem when I use script instance member.

esb.requestBodySearch().sort(
    esb.sort()
    .type('number')
    .script(
        esb.script('inline', "doc['field_name'].value * params.factor")
            .lang('painless')
            .params({ factor: 1.1 })
    )
    .order('asc')
)

I needed to custom my field value, so I used script instance member. But the third line gives me an error message, Expected 1-2 arguments, but got 0.

I think field type should be optional not essential.

new Sort(field: string, order: string?)

Or Am I missing something? Let me know.
Thank you
Reviewer: @sudo-suhas

TypeError: Argument must be an instance of Query

I've a bool query which looks like the following -

BoolQuery {
  queryType: 'bool',
  _body: { bool: { must: [Array] } },
  _queryOpts:
   { must:
      [ [TermsQuery],
        [TermsQuery],
        [TermsQuery],
        [BoolQuery],
        [RangeQuery] ] } }

Now, i'm creating a query using this -

var query = bob.requestBodySearch().
                              query(aboveBoolQuery).
                              size(10)

I'm seeing following error -

BoolQuery {
  queryType: 'bool',
  _body: { bool: { must: [Array] } },
  _queryOpts:
   { must:
      [ [TermsQuery],
        [TermsQuery],
        [TermsQuery],
        [BoolQuery],
        [RangeQuery] ] } } is of the type object
TypeError: Argument must be an instance of Query
    at checkType (node_modules/elastic-builder/lib/core/util.js:34:15)
    at RequestBodySearch.query (node_modules/elastic-builder/lib/core/request-body-search.js:114:13)

So, it's failing while asserting the type to be Query
Now, what I did was that I commented out the code in util.js inside checkType

    //if (!(instance instanceof type)) {
    //    if (isNil(instance)) {
    //        console.warn('Was expecting instance of ' + type.name + ' but got ' + instance + '!');
    //    } else console.warn(inspect(instance) + ' is of the type ' + (typeof instance === 'undefined' ? 'undefined' : (0, _typeof3.default)(instance)));

    //    throw new TypeError('Argument must be an instance of ' + type.name);
    //}

then everything works just fine. package.json has the following entry for elastic builder - "elastic-builder": "^1.1.0",

I tried to print the constructor name as well for the boolQuery using aboveBoolQuery.constructor.name and it says BoolQuery.
My question is should it even fail in this case when it's able to execute the whole thing successfully if I remove the type check here? Is this a potential problem?

An in-range update of coveralls is breaking the build 🚨

The devDependency coveralls was updated from 3.0.5 to 3.0.6.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

coveralls is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • βœ… coverage/coveralls: First build on greenkeeper/coveralls-3.0.6 at 100.0% (Details).

Commits

The new version differs by 3 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

How can I run aggregations on only the filtered data?

I use a filtered query to get my desired documents, but when I add an aggregation, the aggregation includes other bucket with 0 documents.

Is it possible to 'apply' the aggregation only on the result of the filtered data?

functionScoreQuery generates an invalid query

It doesn't work with a WeightScoreFunction with a filter, for example:
.functions([
esb
.weightScoreFunction()
.filter(builder.matchQuery('test', 'bar'))
.weight(23)
])
In this case you'll get the error: 'no [query] registered for [filter]'

When you just use de functions with an array (even when it's empty) it will work.
So please remove the check voor length === 1

Prefix key

Hi,

first, thank you for your work πŸ‘
Now a little feature request. Since elasticearch 6, you can only create one mapping type per index.
https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html
For this reason, I changed my old types "user" and "tweet" in my mapping to this:

PUT twitter
{
  "mappings": {
    "user": {
      "properties": {
        "name": { "type": "text" },
        "user_name": { "type": "keyword" },
        "email": { "type": "keyword" }
      }
    },
    "tweet": {
      "properties": {
        "content": { "type": "text" },
        "user_name": { "type": "keyword" },
        "tweeted_at": { "type": "date" }
      }
    }
  }
}

Is it possible to add a new method "addPrefixKey" to requestBodySearch()?
The result would be somethink like this:

before:

const requestBody = esb.requestBodySearch()
  .query(esb.matchQuery('message', 'this is a test'));

requestBody.toJSON(); // or print to console - esb.prettyPrint(requestBody)
{
  "query": {
    "match": {
      "message": "this is a test"
    }
  }
}

after

const requestBody = esb.requestBodySearch().addPrefixKey("tweet")
  .query(esb.matchQuery('message', 'this is a test'));

requestBody.toJSON(); // or print to console - esb.prettyPrint(requestBody)
{
  "query": {
    "match": {
      "tweet.message": "this is a test"
    }
  }
}

I think, that would be very helpful in bigger queries and if you would like to upgrade from es <6 to es6.

Thank you

Multi-match search missing bool_prefix type

As you can see with the new search_as_you_type field type, the recommended way to query such fields is with a Multi-match with a bool_prefix type (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-as-you-type.html):

GET my_index/_search
{
  "query": {
    "multi_match": {
      "query": "brown f",
      "type": "bool_prefix",
      "fields": [
        "my_field",
        "my_field._2gram",
        "my_field._3gram"
      ]
    }
  }
}

Unfortunately elastic-builder complains if we try and use that though:

WildcardUtilsServer.ts:62 Error: The 'type' parameter should be one of Set(5) {
  'best_fields',
  'most_fields',
  'cross_fields',
  'phrase',
  'phrase_prefix'
}
    at C:\dev\_projects\vibescout-web-workspace\node_modules\elastic-builder\lib\core\util.js:163:15

So, this new multi-match type needs to be added in as an option in the library.

I'll try make a pull request now.

declaration file declares too much

Hi,

The index.d.ts file has several classes without "export" in front of it, e.g. Query. From my understanding, for an ambient (=declared) namespace, typescript implicitly treats all members as exported. This is wrong in this case, because index.js does not export Query.

This led to an error when trying to import Query and using it with "x instanceof Query". Typescript does not complain because it assumes Query exists as value and type - but at runtime, Query is undefined, result:
TypeError: Right-hand side of 'instanceof' is not an object

Maybe the solution is declaring these classes as interfaces. Or export e.g. Query, so instanceof checks can be done ;)

regards,
Thomas

Deprecation warning with hasChildQuery

Deprecated field [child_type] used, expected [type] instead

Generated query:

{
     "has_child": {
        "child_type": "child_documents",
        "query": {
        "bool": {
            "must": [
                ...

Used version: 1.0.0

Please make it immutable or clonale

eg:

  // suppose we write some base aggs
  const groupByOne = esb.termsAggregation('one', 'one');
  const groupByTwo = esb.termsAggregation('two', 'two');
  const groupByThree = esb.termsAggregation('three', 'three');

  // and then let's compose them
  const oneTwoThree = groupByOne.agg(groupByTwo.agg(groupByThree));
  const ThreTwoOne = groupByThree.agg(groupByTwo.agg(groupByOne));
  
  // oops...circular

TermsAggreagation showTermDocCountError parameter of type object instead of boolean

Expected:
When building a TermsAggregation, we are able to add showTermDocCountError with a value of true/false to enable/disable the field in the results.
Actual:
When building a TermsAggregation, we are NOT able to add showTermDocCountError with a value of true/false to enable/disable the field, because the parameter is of type object.

Support for an array of aggregations

For convenience it may be nice if the aggregation/agg method could support being given an array of aggregation types, or separate aggregations/aggs method added to the core aggregation class. For example:

const AGGS_TAG_TYPES = [ ... ]

function bucket (name, type) {
	return builder
		// Filter annotations to given type
		.filterAggregation(
			name,
			builder.termQuery('tags.type', type)
		)
		.aggregation(
			// Create a bucket of unique UUIDs
			builder
				.termsAggregation('tag_ids', 'tags.id')
				.size(10)
		)
}

function aggregations () {
	return builder
		.nestedAggregation('popular_tags', 'tags')
		.aggs(AGGS_TAG_TYPES.map(([ name, type ]) => bucket(name, type))
}

I think this would help to keep the API fluent, what do you think? I'd be happy to help implement this if you think it would be a useful addition.

Sort.toJSON() wrong format!?

let sortField = new Sort('MyFieldToSort', 'desc');

sortField.toJSON()

Result:
{ MyFieldToSort: 'desc' }

Expected result:
{ "MyFieldToSort": { "order": "desc" } }

Consider adding browsers with at least 1% to .babelrc

I really enjoy working with elastic-builder to develop queries, and have we use it quite heavily in our web apps.

I do however need to support a number of browsers that do not currently support a number of "modern" ES features, such as template strings. This means that I am currently unable to use elastic-builder as the node>=4 babel env is outputting code that can not be consumed.

I was hoping you would consider adding "browsers": [">1%"] to your .babelrc to output code that is compatible with a wide range of browsers as well as Node JS.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected πŸ€–


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

functionScoreQuery generates invalid query

I made a functionScoreQuery like this:
esbuilder.functionScoreQuery() .query(mainFilter) .functions(functions) .scoreMode('sum') .boostMode('replace') .minScore(0);

functions is an array of weightScoreFunction. The above query works well if the arrays has more than 1 elements. But in case of only 1 element, it generates an invalid query like this:
POST opportunities/opportunity/_search { "query": { "function_score": { "query": { "match_all": {} }, "score_mode": "sum", "boost_mode": "replace", "min_score": 0, "filter": { "match": { "job_title": "Junior Nodejs" } }, "weight": 33.33333333333333 } }, "from": 0, "size": 5 }

Any help please?

Thanks

QueryStringQuery.escape() implementation not working / not clear

When setting QueryStringQuery.escape() to 'true', it seems the implementation simply adds "escape": "true" to the ES request,
According to the ES query string query documentation, there is no such parameter, and it's the client's responsibility to escape the query string.
Can you please shed some light about the usage of this parameter?

Chaining doesn't work as expected

Hi there,

I am currently using bodybuilder and found this builder. It looks great and we want to switch over. However, we have run into some issues just now. Can you have a look at below:

We are looking to get the following:

{
  "from": 0,
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {
          "matchAll": {
            "boost": 1.2
          }
        },
        {
          "terms": {
            "user": [
              "kimchy",
              "elastic"
            ]
          }
        },
        {
          "fuzzy": {
            "user": {
              "value": "ki",
              "fuzziness": 2,
              "prefix_length": 0,
              "max_expansions": 100,
              "boost": 1
            }
          }
        }
      ]
    }
  }
}

Here is the bodybuilder to make that happen:

bodybuilder()
        .query('matchAll', {boost: 1.2})
	.query('terms', 'user', ['kimchy', 'elastic'])
	.query('fuzzy', 'user', {
          "value": "ki",
          "fuzziness": 2,
          "prefix_length": 0,
          "max_expansions": 100,
          "boost": 1
        })
	.from(0)
	.size(10)
        .build()

We are trying to do the same using https://elastic-builder.js.org/

const qry = esb.matchAllQuery().boost(1.2);
const qry2 = esb.termsQuery('user', ['kimchy', 'elastic']);
const qry3 = esb.fuzzyQuery('user', 'ki')
    .fuzziness(2)
    .prefixLength(0)
    .maxExpansions(100)
    .boost(1.0);

esb.requestBodySearch()
    .query(qry)
    .query(qry2)
    .query(qry3)
    .from(0)
    .size(10);

Produces:

{
  "query": {
    "fuzzy": {
      "user": {
        "value": "ki",
        "fuzziness": 2,
        "prefix_length": 0,
        "max_expansions": 100,
        "boost": 1
      }
    }
  },
  "from": 0,
  "size": 10
}

I'm sure I'm just using this wrongly :-)

Convert query objects to query string

Is it possible to convert query objects to query string? Like the following object...

{
  "query": {
    "bool": {
      "must": {
        "match": {
          "message": "this is a test"
        }
      },
      "filter": [
        {
          "term": {
            "user": "kimchy"
          }
        },
        {
          "term": {
            "user": "herald"
          }
        }
      ],
      "must_not": {
        "term": {
          "user": "cassie"
        }
      },
      "should": {
        "term": {
          "user": "johnny"
        }
      }
    }
  },
  "aggs": {
    "user_terms": {
      "terms": {
        "field": "user"
      }
    }
  }
}

Example in README seems to be broken

Hi, I'm doing this;

const requestBody = bob.requestBodySearch()
.query(
    bob.boolQuery()
        .must(bob.matchQuery('last_name', 'smith'))
        .filter(bob.rangeQuery('age').gt(30))
)
console.log(JSON.stringify(requestBody.toJSON()));

which is giving me

 {"query":{"bool":{"filter":{"range":{"age":{"gt":30}}}}}}

so no inclusion of the "must" clause...

Am I doing something wrong?

Future roadmap

Hi. Can you please share your future vision for this module? Are you planning on actively supporting it? Is it going to be compatible with latest ES stable release? Thank you.

Invalid declaration file index.d.ts

Hello,

I wanted to utilize the elastic-builder (1.0.2), however during typescript transpilation I get the following error:

ERROR in node_modules/elastic-builder/index.d.ts (280,1): A 'declare' modifier is required for a top level declaration in a .d.ts file.

this refers to the top-level definition:

class Query {

which is not allowed since typescript 0.9. (https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9)

Could you adapt your building / publishing procedure to produce a valid declaration file?

Possible bug found when passing a query as a parameter into esb.requestBodySearch().query(...)

Hi,

I'm doing a proof of concept using ElasticSearch, so it's worth noting that this is my first interaction both with ElasticSearch and elastic-builder.

I went through the docs and found the following example:

const reqBody = esb.requestBodySearch()
    .query(esb.matchAllQuery())
    .highlight(esb.highlight('title'));

This, unfortunately, throws an error:

"err": {
        "msg": "[parsing_exception] no [query] registered for [query], with { line=1 & col=19 }",
        "path": "/_all/_doc/_search",
        "query": {},
        "body": "{\"query\":{\"query\":{\"match_all\":{}},\"highlight\":{\"fields\":{\"title\":{}}}}}",
        "statusCode": 400,
        "response": "{\"error\":{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"no [query] registered for [query]\",\"line\":1,\"col\":19}],\"type\":\"parsing_exception\",\"reason\":\"no [query] registered for [query]\",\"line\":1,\"col\":19},\"status\":400}"
    }

I think the problem is that in the body, there's a 'query' property, which also has a 'query' property inside of it.

Actually, my use case is a bit more complicated. What I'm trying to do is pass 'esb.boolQuery' as a parameter to the esb.requestBodySearch().query(). I'm doing this because I also want to use highlight(), size() and from().
I thought I was doing something wrong, but it turned out that it's the same when using the example from the docs.

So is there a way to pass an 'esb.boolQuery' as a parameter to 'esb.requestBodySearch().query()' ?

Thank you.

whether support range date query in elasticsearch6.8.0 ?

hi,
i want to query with range date, like below example:

{
  "from": 0,
  "size": 1000,
  "query": {
    "bool": {
      "must": {
        "exists": { "field": "test" }
      },
      "filter": {
        "range": {
          "CreateDate": {
            "gte": "06/06/2019",
            "lt": "30/09/2019",
            "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis||dd/MM/yyyy||yyyy"
          }
        }
      }
    }
  }
}

i use below elastic-builder js clause,

const requestBody = esb.requestBodySearch()
    .from(0).size(1000)
    .query(
        esb.boolQuery()
            .must(esb.existsQuery('test'))
            .filter(esb.rangeQuery('CreateDate').gt('06/06/2019'))
    );

but meet with below exception:

race: [parse_exception] failed to parse date field [06/06/2019] with format [strict_date_optional_time||epoch_millis]

i want to know how do let me support this range date query, or not support it? thanks

edit: formatting

Types for geo shape query coordinates seem to be incorrect

I'm getting a type error while trying to create a geo shape query like so:

esb.geoShapeQuery("geoShape")
      .shape(
        esb.geoShape("envelope").coordinates([[topLeft.lon, topLeft.lat], [bottomRight.lon, bottomRight.lat]])
      )

The error is showing up over the parameters passed to coordinates():

TS2322: Type 'number[]' is not assignable to type 'number'.

So I think there is a problem, and the correct type is an array of number[] - so number[][].

Create query from object/json

Hi,

I have a case where parts of the query comes from the back end. Problem now is that I can't find a way to convert a object into a Query object.

I have found a hack but it feels so wrong. Is there a "right" way to do this?

let subQuery = new bob.BoolQuery();
subQuery._body = resp.data.query;
subQuery._queryOpts = resp.data.query.bool;

let query = bob.requestBodySearch()
    .size(5)
    .query(subQuery);

Thanks for a cool query builder!

Morten

Extending Query

Hi, I'd like to be able to extend Query to be able to do some custom things, would it be possible to expose the Query object.
It's also a bit misleading to have the Query object type available in TypeScript but not be able to export it.
Maybe I could create a pull request for that.

Thanks.

Using terminate after and index on a term query

I am probably missing something really obvious, but when I try to use requestBodySearch() with terminateAfter() or index() I get errors.

var requestBody = bob.requestBodySearch()
        .query(bob.termQuery('myId', 7181909))
        .terminateAfter(1);

elasticsearchClient.search(requestBody.toJSON(), function(error, results){

The result I get from elastic-builder is { query: { term: { myId: '7181909' } }, terminate_after: 1 }

Running that causes an error: [illegal_argument_exception] request [/_search] contains unrecognized parameter: [query]

What I need is {index: 'myIndex', terminateAfter:1, body: { query: { term: { myId: '7181909' } } } }

Can elastic-builder build the whole query like this for the js API? I assume I'm using it completely wrong, it works when I put the requestBody of a simple query in the body of a query using the elasticsearch js api, but as you have terminateAfter in the docs I assume I should be able to get this to work (though it's terminateAfter, not terminate_after in the js API, different from the REST API).

Thanks

Add arbitrary key/ value pairs to request body

Szenario

For a provider specific implementation, we need to add some additional arbitrary key/ value pairs to a esb.requestBodySearch() object.

Example

const query = esb.requestBodySearch()
    .query( esb.matchAllQuery() )
    .sort( esb.sort('created_at', 'desc') )
    .arbitrayFields( {
        raw: true,
        page: 1,
        per_page: 100,
        include: [
            "name",
            "created_at",
            "email",
            "…",
        ]
    } );

The only "solution" we could come up so far (we are not using TypeScript) is to convert the requestBody to JSON and extending the object itself. We really dislike this approach as we want to pass around esb objects, rather than the JSON string to have all of the packages/ libraries possibilities at hand when we need it.

let requestBody = query.toJSON();
Object.assign( requestBody, {
    raw: true,
    page: 1,
    per_page: 100,
    include: [
        "name",
        "created_at",
        "email",
        "…",
    ]
} );

Thanks!

BoolQuery should function does not work

When I use the Should function of the BoolQuery, the following error occurs

TypeError: this._queryOpts[clause].push is not a function
    at BoolQuery._addQuery (node_modules/elastic-builder/lib/queries/compound-queries/bool-query.js:83:37)
    at /Workspace/bbros/ddocdoc-search-server/node_modules/elastic-builder/lib/queries/compound-queries/bool-query.js:103:31
    at Array.forEach (<anonymous>)
    at BoolQuery._addQueries (node_modules/elastic-builder/lib/queries/compound-queries/bool-query.js:102:49)
    at BoolQuery.should (node_modules/elastic-builder/lib/queries/compound-queries/bool-query.js:184:18)
    at getBoolQuery (server/api/beauty-search/service/beauty-search-surgery-reviews.service.js:13:6)
    at buildElasticQuery (server/api/beauty-search/service/beauty-search-surgery-reviews.service.js:21:10)
    at getEsRequestBody (server/api/beauty-search/service/beauty-search-surgery-reviews.service.js:39:10)
    at searchProcess (server/api/beauty-search/service/beauty-search-surgery-reviews.service.js:42:23)
    at Object.module.exports.exec.query [as exec] (server/api/beauty-search/service/beauty-search-surgery-reviews.service.js:49:32)
    at Context.it (server/api/beauty-search/service/spec/beauty-search-surgery-reviews.service.spec.js:12:29)
    at process.topLevelDomainCallback (domain.js:120:23)

Use Code

new esb.BoolQuery()
    .should([
      new esb.MultiMatchQuery(MULTI_MATCH_FIELDS, query.query_string)
        .type('cross_fields')
        .operator('and'),
    ])

Support Multiple Documents in Percolate Queries

Would you accept a PR that added functionality for percolating many documents? https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-percolate-query.html

And if so, how would you see the interop with PercolateQuery#document?

esb.percolateQuery('field', 'doc-type')
   .document({ name: 'some doc' })
   .documents([{name: 'another doc'}]) // throw an error? Merge with existing docs? Let me know what is more in the style of this package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.