Php 在CouchDB中使用弹性搜索查询内部数组
我的CouchDB数据库的结构如下:Php 在CouchDB中使用弹性搜索查询内部数组,php,rest,lucene,couchdb,
elasticsearch,Php,Rest,Lucene,Couchdb,
elasticsearch,我的CouchDB数据库的结构如下: "custom_details": { "user_education": [ { "device_id": "358328030246627", "college_name": "College", "college_year": "2014" }, ] } "custom_details_1": { "user_education": [ { "device_id":
"custom_details": {
"user_education": [
{
"device_id": "358328030246627",
"college_name": "College",
"college_year": "2014"
},
]
}
"custom_details_1": {
"user_education": [
{
"device_id": "358328030246627",
"college_name": "College",
"college_year": "2014"
},
]
}
我在数组中有很多数组。我尝试使用Elasticsearch来搜索和查找术语,而不管它在数组中的位置如何。可能吗
我已经看过了上面的例子,还没有完全找到我要找的。我尝试过使用PHP包装器Elastica,但没有完全理解如何使用REST实现这一点,我迷路了。甚至可以在不知道字段的情况下搜索数据吗?在Lucene中,您可以为每个设备id创建一个文档实例:
public void indexRecord(CouchDBRecord rec) {
Document doc = new Document();
doc.add(new Field("device_id", rec.device_id, Store.YES, Index.NOT_ANALYZED));
doc.add(new Field("college_name", rec.college_name, Store.YES, Index.ANALYZED));
doc.add(new Field("college_year", rec.college_year.toString(), Store.YES, Index.NOT_ANALYZED));
this.writer.addDocument(doc);
}
这将允许您通过学院名称中的关键字、确切的设备id或年份或它们的组合进行搜索。如果您使用的是Elastica,那么剩下的一切都已经为您完成了。如果要在所有字段中搜索,可以只定义搜索词,它将在所有字段中搜索
如果您在Elastica方面遇到了一些问题,或者您需要的某些功能缺失,请告诉我,因为我是Elastica的开发人员。你好,Nicolas Ruflin,我正在与couchdb一起进行elastic搜索。我有点困惑,我如何一次管理多个用户的索引。对于一个用户来说,它工作得很好,但当我同时尝试多个用户时,它有警告(org.apache.commons.httpclient.SimpleHttpConnectionManager getConnectionWithTimeout警告:SimpleHttpConnectionManager使用不正确。请确保始终调用HttpMethod.releaseConnection(),并且一次只有一个线程和/或方法使用此连接管理器。)