Match all query

Match all query

The most simple query, which matches all documents, giving them all a _score of 1.0.

  1. $params = [
  2. 'body' => [
  3. 'query' => [
  4. 'match_all' => [
  5. ],
  6. ],
  7. ],
  8. ];
  9. $response = $client->search($params);
  1. resp = client.search(
  2. query={
  3. "match_all": {}
  4. },
  5. )
  6. print(resp)
  1. response = client.search(
  2. body: {
  3. query: {
  4. match_all: {}
  5. }
  6. }
  7. )
  8. puts response
  1. res, err := es.Search(
  2. es.Search.WithBody(strings.NewReader(`{
  3. "query": {
  4. "match_all": {}
  5. }
  6. }`)),
  7. es.Search.WithPretty(),
  8. )
  9. fmt.Println(res, err)
  1. const response = await client.search({
  2. query: {
  3. match_all: {},
  4. },
  5. });
  6. console.log(response);
  1. GET /_search
  2. {
  3. "query": {
  4. "match_all": {}
  5. }
  6. }

The _score can be changed with the boost parameter:

  1. resp = client.search(
  2. query={
  3. "match_all": {
  4. "boost": 1.2
  5. }
  6. },
  7. )
  8. print(resp)
  1. response = client.search(
  2. body: {
  3. query: {
  4. match_all: {
  5. boost: 1.2
  6. }
  7. }
  8. }
  9. )
  10. puts response
  1. res, err := es.Search(
  2. es.Search.WithBody(strings.NewReader(`{
  3. "query": {
  4. "match_all": {
  5. "boost": 1.2
  6. }
  7. }
  8. }`)),
  9. es.Search.WithPretty(),
  10. )
  11. fmt.Println(res, err)
  1. const response = await client.search({
  2. query: {
  3. match_all: {
  4. boost: 1.2,
  5. },
  6. },
  7. });
  8. console.log(response);
  1. GET /_search
  2. {
  3. "query": {
  4. "match_all": { "boost" : 1.2 }
  5. }
  6. }

Match None Query

This is the inverse of the match_all query, which matches no documents.

  1. resp = client.search(
  2. query={
  3. "match_none": {}
  4. },
  5. )
  6. print(resp)
  1. response = client.search(
  2. body: {
  3. query: {
  4. match_none: {}
  5. }
  6. }
  7. )
  8. puts response
  1. res, err := es.Search(
  2. es.Search.WithBody(strings.NewReader(`{
  3. "query": {
  4. "match_none": {}
  5. }
  6. }`)),
  7. es.Search.WithPretty(),
  8. )
  9. fmt.Println(res, err)
  1. const response = await client.search({
  2. query: {
  3. match_none: {},
  4. },
  5. });
  6. console.log(response);
  1. GET /_search
  2. {
  3. "query": {
  4. "match_none": {}
  5. }
  6. }