Skip to content
Snippets Groups Projects
Select Git revision
  • 30fb9aef170bceb05d6a29ddfcbc70bc72bbda70
  • master default protected
  • symfony-serializer-7
3 results

Indices.md

Blame
  • user avatar
    Aivaras Gotovskis authored
    2fa61b15
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Indices.md 1.04 KiB

    Indices Filter

    More info about indices filter is in the official elasticsearch docs

    The indices filter can be used when executed across multiple indices, allowing to have a filter that executes only when executed on an index that matches a specific list of indices, and another filter that executes when it is executed on an index that does not match the listed indices.

    Simple example

    {
        "indices" : {
            "indices" : ["index1", "index2"],
            "filter" : {
                "term" : { "tag" : "wow" }
            },
            "no_match_filter" : {
                "term" : { "tag" : "kow" }
            }
        }
    }

    And now the query via DSL:

    $termFilter1 = new TermFilter('tag', 'wow');
    $termFilter2 = new TermFilter('tag', 'kow');
    
    $indicesFilter = new IndicesFilter(
        ['index1', 'index2'],
        $termFilter1,
        $termFilter2
    );
    
    $search = new Search();
    $search->addFilter($indicesFilter);
    
    $queryArray = $search->toArray();