5

私は以下のような文書を持っています:

{
    "_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": [{
            "id": 1
        }, {
            "id": 2
        }, {
            "id": 3
        }, {
            "id": 6
        }],
        "properties": [{
            "id": 4
        }]
    }
}

武器に基づいてユーザーを一致させる必要があり、次のようなことを試みています:

$params = [
            'index' => Constants::INDEX,
            'type' => Constants::DOC_TYPE_USERS,
            'body' => [
                "query"=> [
                    "bool"=> [
                        "must"=>   [ "match"=> [ "weapons.id"=>$params['weapons'] ]],

                        "should"=> [
                                    [ "match"=> [ "firstname"=> $params['search_text'] ]],
                                    [ "match"=> [ "lastname"=> $params['search_text']   ]]
                                        ]
                                    ]
                            ]
                        ]

                ];

PHPでエラスティックを使用しているため。$params['weapons'] は次のとおりです。

array (size=2)
  0 => string '1' (length=1)
  1 => string '2' (length=1)

エラーが発生します:

illegal_state_exception: 1:36 の START_ARRAY でテキストを取得できません

配列をどのように一致させることができるかについての提案/ヘルプをいただければ幸いです。ネストされたデータ型から参照しました

Update#1 : 関数に送信するパラメーター:{"from":0,"size":null,"city":null,"state":"0","weapons":["1","2"],"activities":[],"species":[],"properties":[],"search_text":"lastname"}

update#2 : json 形式のクエリの本文:

{
    "index": "abc_local",
    "type": "users",
    "body": {
        "query": {
            "bool": {
                "must": {
                    "match": {
                        "weapons.id": ["1", "2"]
                    }
                },
                "should": [{
                    "match": {
                        "firstname": "simer"
                    }
                }, {
                    "match": {
                        "lastname": "simer"
                    }
                }]
            }
        }
    }
}
4

2 に答える 2