Elasticsearch 7.x client for JS with faceted search, custom features and simple interface
- faceted search
- full text
- pagination
- sorting
npm install elasticitemsconstelasticitems=require('elasticitems')(es_config,search_config);elasticitems.search().then(result=>{console.log(result);})The first es_config is elasticsearch configuration object and contains values like host, index or type.
Responsible for defining global configuration.
aggregationsfilters configuration i.e. fortags,actors,colors, etc. Responsible for generating facets.sortingsyou can configure different sortings liketags_asc,tags_descwith options and later use it with one key.
per_pageamount of items per page.pagepage number - used for pagination.queryused for full text search.operatorsearch operatorandandor(default). It works withqueryparametersortused for sorting. one ofsortingskeyfiltersfiltering items based on specific aggregations i.e. {tags: ['drama' , 'historical']}query_stringi.e. "brand:Audi OR brand:Mercedes"facets_namesmake faceted search only for specific fields i.e. ['tags', 'genres']fieldssearch only in specifc fields i.e. ['name', 'description']. Missing parameter means search in all fieldsidssearch by ids i.e. ['1', '2', '3']exclude_idsexclude ids from search i.e. ['1', '2', '3']
Show similar items based on collaborative filtering
fieldsi.e ['tags'].
It returns full list of filters for specific aggregation
nameaggregation nameper_pagefilters per pagesizehow much load into memory (for pagination)pagepage numbersortresponsible for sorting mechanism. It can be_countor_termorderresponsible for an order. It can beascordescfiltersfilter this aggregation through another aggregations (facets)aggregation_queryused for quering filters. It's not full text searchquerysearch through itemsquery_stringsearch through items by query string i.e. (category:Garden and color:red)
Returns found record otherwise throw an error
Returns record based on key and value
Add a new object into index. Provide your own id if you don't want it auto-generated
Updates object in index
Delete object from index
- Full text search does not work on
keywordtype because this type is not tokenized.keywordtype is great for faceted fields
npm test