使用 Elastic Search 查询 CouchDB 中的数组内部
我的 CouchDB 数据库的结构如下:
"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 来搜索和查找术语,无论它位于数组中的哪个位置。这可能吗?
我已经浏览了此处上的示例,但还没有完全了解找到了我要找的东西。我尝试过使用 Elastica(PHP 包装器),但由于没有完全理解如何使用 REST 来实现这一点,所以我迷失了方向。是否可以在不了解领域的情况下搜索数据?
My CouchDB database is structured like this:
"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"
},
]
}
I have a lot of arrays within arrays. What I'm trying to do use Elasticsearch to search and find terms, regardless of where it's sitting in an array. Is that possible?
I've been going through the examples on here and haven't quite found what I'm looking for. I've tried using Elastica, the PHP Wrapper, but without fully understanding how to do this with REST, I'm lost. Is it even possible to search for data without knowing the field?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Lucene 中,您可以为每个设备 ID 创建一个文档实例:
这将允许您通过大学名称中的关键字、或者通过确切的设备 ID 或年份、或者它们的某种组合进行搜索。
In Lucene, you could create a document instance for each device id:
This will allow you to search by keywords in the college name, or by exact device id or year, or some combination thereof.
如果您使用 Elastica,那么整个 REST 事情已经为您完成。如果您想在所有字段中搜索,您可以只定义搜索词,它将在所有字段中搜索。
如果您在使用 Elastica 时遇到一些问题,或者缺少您需要的某些功能,请告诉我,因为我是 Elastica 的开发人员。
If you are using Elastica, the whole REST thing is already done for you. If you want to search in all fields, you can define just the search term and it will search in all fields.
If you are having some troubles with Elastica or if some features are missing you need, let me know, as I'm the developer of Elastica.