sudo-suhas/elastic-builder

Support distance_feature

ivan-kuzma-scx opened this issue · 2 comments

Hello, could you please help to figure out if distance_feature is supported by elastic-builder?

If no, what is the way to use raw query inside nested bool query?

https://www.elastic.co/guide/en/elasticsearch/reference/7.13/query-dsl-distance-feature-query.html

I also faced the same issue. will be glad to receive your help

It is not currently supported in elastic-builder. A PR would be more than welcome.

If no, what is the way to use raw query inside nested bool query?

It would be possible to use a custom class that extends Query.

const esb = require("elastic-builder");
const { Query } = require("elastic-builder/lib/core");

class CustomQuery extends Query {
	constructor(field) {
		super("distance_feature", field);
	}

	pivot(pivot) {
		this._queryOpts.pivot = pivot;
		return this;
	}
}

esb.prettyPrint(
	esb.boolQuery().must(new CustomQuery("production_date").pivot("7d"))
);