_tier field

_tier field

When performing queries across multiple indexes, it is sometimes desirable to target indexes held on nodes of a given data tier (data_hot, data_warm, data_cold or data_frozen). The _tier field allows matching on the tier_preference setting of the index a document was indexed into. The preferred value is accessible in certain queries :

  1. resp = client.index(
  2. index="index_1",
  3. id="1",
  4. document={
  5. "text": "Document in index 1"
  6. },
  7. )
  8. print(resp)
  9. resp1 = client.index(
  10. index="index_2",
  11. id="2",
  12. refresh=True,
  13. document={
  14. "text": "Document in index 2"
  15. },
  16. )
  17. print(resp1)
  18. resp2 = client.search(
  19. index="index_1,index_2",
  20. query={
  21. "terms": {
  22. "_tier": [
  23. "data_hot",
  24. "data_warm"
  25. ]
  26. }
  27. },
  28. )
  29. print(resp2)
  1. response = client.index(
  2. index: 'index_1',
  3. id: 1,
  4. body: {
  5. text: 'Document in index 1'
  6. }
  7. )
  8. puts response
  9. response = client.index(
  10. index: 'index_2',
  11. id: 2,
  12. refresh: true,
  13. body: {
  14. text: 'Document in index 2'
  15. }
  16. )
  17. puts response
  18. response = client.search(
  19. index: 'index_1,index_2',
  20. body: {
  21. query: {
  22. terms: {
  23. _tier: [
  24. 'data_hot',
  25. 'data_warm'
  26. ]
  27. }
  28. }
  29. }
  30. )
  31. puts response
  1. const response = await client.index({
  2. index: "index_1",
  3. id: 1,
  4. document: {
  5. text: "Document in index 1",
  6. },
  7. });
  8. console.log(response);
  9. const response1 = await client.index({
  10. index: "index_2",
  11. id: 2,
  12. refresh: "true",
  13. document: {
  14. text: "Document in index 2",
  15. },
  16. });
  17. console.log(response1);
  18. const response2 = await client.search({
  19. index: "index_1,index_2",
  20. query: {
  21. terms: {
  22. _tier: ["data_hot", "data_warm"],
  23. },
  24. },
  25. });
  26. console.log(response2);
  1. PUT index_1/_doc/1
  2. {
  3. "text": "Document in index 1"
  4. }
  5. PUT index_2/_doc/2?refresh=true
  6. {
  7. "text": "Document in index 2"
  8. }
  9. GET index_1,index_2/_search
  10. {
  11. "query": {
  12. "terms": {
  13. "_tier": ["data_hot", "data_warm"]
  14. }
  15. }
  16. }

Querying on the _tier field

Typically a query will use a terms query to list the tiers of interest but you can use the _tier field in any query that is rewritten to a term query, such as the match, query_string, term, terms, or simple_query_string query, as well as prefix and wildcard queries. However, it does not support regexp and fuzzy queries.

The tier_preference setting of the index is a comma-delimited list of tier names in order of preference i.e. the preferred tier for hosting an index is listed first followed by potentially many fall-back options. Query matching only considers the first preference (the first value of a list).