CouchDB和弹性搜索的独特选择 [英] Distinct selection with CouchDB and elasticsearch

查看:102
本文介绍了CouchDB和弹性搜索的独特选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有CouchDB / 弹性搜索设置。 CouchDB作为存储,用于搜索的弹性搜索。



我需要执行此查询,

 从表中选择不同的名称

>table

  [
{name:'david' ...更多数据},
{name:'david'...更多数据},
{name:'alex'...更多数据}
{name:'alex' ...更多数据}
]

得到这个:

  ['david','alex'] 

或者这个:

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

或以任何形式,但不同的查询结果。



使用CouchDB可以通过以下方式完成:

  // map 
function(doc){
emit(doc.name);
}

// reduce
function(keys,values){
return null;
}

但是我想使用弹性搜索来做到这一点。有一些信息在网络上,但不清楚。



有人可以指出我正确的方向来实现我想要的吗?

解决方案

您可以使用名称。


条款方面查询

I have this CouchDB/elasticsearch setup. CouchDB as a storage, elasticsearch for search.

I need to execute this query,

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 this:

  ['david', 'alex']

or this:

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

or in whatever form but the result of a distinct query.

Using CouchDB it can be done by this:

// map
function(doc) {
    emit(doc.name);
}

// reduce
function(keys, values) {
   return null;
}

But I want to use elasticsearch to do it. There is some info on the web but is not clear.

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

解决方案

You can do it using Terms Facet Query on the field name.

这篇关于CouchDB和弹性搜索的独特选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆