Skip to content
Snippets Groups Projects
Commit 693aca74 authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge pull request #25 from mansimas/patch_docs

Patch docs
parents 62a00e71 a5e313a5
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ built - one per unique value. ...@@ -10,7 +10,7 @@ built - one per unique value.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_genders" : { "genders" : {
"terms" : { "field" : "gender" } "terms" : { "field" : "gender" }
} }
} }
......
...@@ -16,7 +16,7 @@ so that the top matching documents can be aggregated per bucket. ...@@ -16,7 +16,7 @@ so that the top matching documents can be aggregated per bucket.
"field": "tags", "field": "tags",
"size": 3 "size": 3
}, },
"aggs": { "aggregations": {
"top_tag_hits": { "top_tag_hits": {
"top_hits": { "top_hits": {
"sort": [ "sort": [
......
...@@ -8,7 +8,7 @@ A single-value metrics aggregation that counts the number of values that are ext ...@@ -8,7 +8,7 @@ A single-value metrics aggregation that counts the number of values that are ext
```JSON ```JSON
{ {
"aggs" : { "aggregations" : {
"grades_count" : { "value_count" : { "field" : "grade" } } "grades_count" : { "value_count" : { "field" : "grade" } }
} }
} }
......
...@@ -41,12 +41,16 @@ $termQueryForTag1 = new TermQuery("tag", "wow"); ...@@ -41,12 +41,16 @@ $termQueryForTag1 = new TermQuery("tag", "wow");
$termQueryForTag2 = new TermQuery("tag", "elasticsearch"); $termQueryForTag2 = new TermQuery("tag", "elasticsearch");
$rangeQuery = new RangeQuery("age", ["from" => 10, "to" => 20]); $rangeQuery = new RangeQuery("age", ["from" => 10, "to" => 20]);
$bool = new BoolQuery();
$bool->addParameter("minimum_should_match", 1);
$bool->addParameter("boost", 1);
$bool->add($termQueryForUser, BoolQuery::MUST);
$bool->add($rangeQuery, BoolQuery::MUST_NOT);
$bool->add($termQueryForTag1, BoolQuery::SHOULD);
$bool->add($termQueryForTag2, BoolQuery::SHOULD);
$search = new Search(); $search = new Search();
$search->addQuery($termQueryForUser, BoolQuery::MUST); $search->addQuery($bool);
$search->addQuery($rangeQuery, BoolQuery::MUST_NOT);
$search->addQuery($termQueryForTag1, BoolQuery::SHOULD);
$search->addQuery($termQueryForTag2, BoolQuery::SHOULD);
$search->setBoolQueryParameters(["minimum_should_match" => 1, "boost" => 1]);
$queryArray = $search->toArray(); $queryArray = $search->toArray();
``` ```
......
# Wildcard Query # Wildcard query
\ No newline at end of file
> More info about Wildcard query is in the [official elasticsearch docs][1]
Matches documents that have fields matching a wildcard expression (not analyzed).
Lets take an example to write a wildcard query with Elasticsearch DSL.
```JSON
{
"wildcard" : {
"user" : {
"value" : "ki*y"
},
"boost" : 2.0
}
}
```
And now the query via DSL:
```php
$search = new Search();
$wildcard= new WildcardQuery('user', 'ki*y', ["boost" => 2.0]);
$search->addQuery($wildcard);
$queryArray = $search->toArray();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment