使用CouchDB的 - lucene的操作方法在CouchDB中数组索引(标签) [英] How-to index arrays (tags) in CouchDB using couchdb-lucene

查看:105
本文介绍了使用CouchDB的 - lucene的操作方法在CouchDB中数组索引(标签)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的设置:

我有一个使用CouchDB的一个项目。该文件将有一个叫做标签字段中。这个标签字段是一个字符串数组(例如,标签:TAG1,标签2,等])。我使用CouchDB的 - lucene的作为我的搜索提供商。

I have a project that is using CouchDB. The documents will have a field called "tags". This "tags" field is an array of strings (e.g., "tags":["tag1","tag2","etc"]). I am using couchdb-lucene as my search provider.

问题:

什么功能可以被用来获取CouchDB的,Lucene来索引标签?

What function can be used to get couchdb-lucene to index the elements of "tags"?

如果你有一个想法,但没有测试环境,键入出来,我来试试这里给出的结果。

If you have an idea but no test environment, type it out, I'll try it and give the result here.

推荐答案

那么这是很容易后,我想通了。请意识到$字符没有意义的code,我在这种情况下,仅仅领域以$开头。发表任何人的回答在未​​来这个问题。

Well it was quite easy after I figured it out. Please realize that the $ character has no significance to the code, my fields in this case just begin with $. Posted the answer for anyone with this question in the future.

function(doc) {
  var result = new Document();
  for(var i in doc.$tags) {
    result.add(doc.$tags[i]);
  }
  return result;
}

这篇关于使用CouchDB的 - lucene的操作方法在CouchDB中数组索引(标签)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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