Great choice with CouchDB and elasticsearch

I have a CouchDB / elasticsearch setup. CouchDB as a repository, search for search results.

I need to fulfill this request,

select distinct name from table 

in this "table"

 [ {name:'david' ... more data}, {name:'david' ... more data}, {name:'alex' ... more data} {name:'alex' ... more data} ] 

to get the following:

  ['david', 'alex'] 

or that:

  [ {name:'david'}, {name:'alex'} ] 

or in any form, but the result of a separate request.

Using CouchDB can be done as follows:

 // map function(doc) { emit(doc.name); } // reduce function(keys, values) { return null; } 

But I want to use elasticsearch to do this. There is some information on the Internet, but is not clear.

Can someone point me in the right direction to achieve what I want?

+1
source share
1 answer

You can do this using the Facet Query Conditions in the name field.

+2
source

Source: https://habr.com/ru/post/1494318/


All Articles