ruflin / Elastica

Elastica is a PHP client for elasticsearch
http://elastica.io/
MIT License
2.26k stars 733 forks source link

Is it possible to add raw query with array? #2207

Closed fico7489 closed 3 months ago

fico7489 commented 3 months ago

I have :


        $matchQuery = new MatchQuery();
        $matchQuery->setField('testString, 'test');
        $query->addShould($matchQuery);

and that gives me:


               "query": {
                    "bool": {
                        "should": [
                            {
                                "match": {
                                    "testString": "test"
                                }
                            }
                        ]
                    }
                }

Now I want something like this:

        $matchQuery = new MatchQuery();
        $matchQuery->setField('testString, 'test');
        $query->addShould($matchQuery);
        $query->addShould(new RawQuery([
             "match": [
                  "testString" => "test2"
              ]
          ]));

to get this in query:

                "query": {
                    "bool": {
                        "should": [
                            {
                                "match": {
                                    "testString": "test"
                                }
                            },
                            {
                                "match": {
                                    "testString": "test2"
                                }
                            }
                        ]
                    }
                }