Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Simple Query String Query

More info about simple query string query is in the official elasticsearch docs

A query that uses the SimpleQueryParser to parse its context

Simple example

{
    "simple_query_string" : {
        "query": "\"fried eggs\" +(eggplant | potato) -frittata",
        "analyzer": "snowball",
        "fields": ["body^5","_all"],
        "default_operator": "and"
    }
}

In DSL:

$simpleQueryStringQuery = new SimpleQueryStringQuery(
    '"fried eggs" +(eggplant | potato) -frittata',
    [
        'analyzer' => 'snowball',
        'fields' => ['body^5', '_all'],
        'default_operator' => 'and',
    ]
);

$search = new Search();
$search->addQuery($simpleQueryStringQuery);

$queryArray = $search->toArray();