标签: elasticsearch-nested

在弹性搜索中匹配数组

我的文件如下:

{
    "_index": "abc_local",
    "_type": "users",
    "_id": "1",
    "_version": 5,
    "found": true,
    "_source": {
        "firstname": "simer",
        "lastname": "kaur",
        "gender": "1",
        "Address": "Punjab House Fed. Housing Society, Amritsar, Punjab, India",
        "email": "rav@yopmail.com",
        "occupation": "Php Developer",
        "work": "Development",
        "fav_hunting_land": 2,
        "zipcode": "",
        "marital_status": "1",
        "phone": "1234567899",
        "school": "sdfergdfh",
        "species": [{
            "id": 1
        }, {
            "id": 2
        }, {
            "id": 3
        }, {
            "id": 4
        }, {
            "id": 5
        }, {
            "id": 6
        }],
        "activities": [{
            "id": 1
        }],
        "fav_weapon": 6,
        "weapons": [{ …
Run Code Online (Sandbox Code Playgroud)

elasticsearch elasticsearch-nested

3
推荐指数
1
解决办法
3245
查看次数

Elasticsearch 6.3.2 的 NestedSortBuilder 使用示例

我必须对使用弹性 Java 高级其余客户端 api 嵌套的一级字段进行排序。我可以找到这个答案

Elasticsearch 嵌套排序

问题是答案使用 SortBuilder 使用以下代码对嵌套字段进行排序:

SortBuilder sb = SortBuilders.fieldSort("authorList.lastName")
    .order(SortOrder.ASC)
    .setNestedPath("authorList")
    .setNestedFilter(matchFirst);
Run Code Online (Sandbox Code Playgroud)

然而,似乎nestedPath 和NestedFilter 在6.3.2 elastic(deprication info)中已被弃用,并且引入了新的NestedSortBuilder。但是我无法使用它构建查询。任何人都可以解释如何使用它,或者给我指出一个使用它的例子吗?

java elasticsearch elasticsearch-nested

3
推荐指数
1
解决办法
1673
查看次数

elasticsearch 5 - 如何查询对象数据类型和嵌套的json数组

我想查询已加载到 Elasticsearch 5 中的嵌套数据,但每个查询都没有返回任何内容。数据是对象数据类型json 嵌套数组

这是嵌套数据类型,即 json 的 team_members 数组:

[{
"id": 6,
"name": "mike",
"priority": 1
}, {
"id": 7,
"name": "james",
"priority": 2
}]
Run Code Online (Sandbox Code Playgroud)

该对象数据类型即availability_slot json:

{
"monday": {
    "on": true,
    "end_time": "15",
    "start_time": "9",
    "end_time_unit": "pm",
    "start_time_unit": "am",
    "events_starts_every": 10
}
}
Run Code Online (Sandbox Code Playgroud)

这是我的弹性搜索映射:

{
"meetings_development_20170716013030509": {
    "mappings": {
        "meeting": {
            "properties": {
                "account": {"type": "integer"},
                "availability_slot": {
                    "properties": {
                        "monday": {
                            "properties": {
                                "end_time": {"type": "text"},
                                "end_time_unit": {"type": "text"},
                                "events_starts_every": {
                                      "type":"integer"
                                }, …
Run Code Online (Sandbox Code Playgroud)

elasticsearch elasticsearch-query elasticsearch-nested elasticsearch-5

2
推荐指数
1
解决办法
1万
查看次数