Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 5.13 KB | None | 0 0
  1. PUT events
  2. {
  3.  "settings": {
  4.   "analysis": {
  5.    "filter": {
  6.     "englishStopWords": {
  7.      "type": "stop",
  8.      "stopwords": "_english_"
  9.     }
  10.    },
  11.    "analyzer": {
  12.     "eventNameAnalyzer": {
  13.      "tokenizer": "standard",
  14.      "filter": [
  15.       "lowercase",
  16.       "englishStopWords"
  17.      ]
  18.     }
  19.    }
  20.   }
  21.  },
  22.  "mappings": {
  23.   "event": {
  24.    "properties": {
  25.     "eventName": {
  26.      "type": "keyword",
  27.      "fields": {
  28.       "analyzed": {
  29.        "type": "text",
  30.        "analyzer": "eventNameAnalyzer",
  31.        "search_analyzer": "eventNameAnalyzer"
  32.       }
  33.      }
  34.     },
  35.     "category": {
  36.      "type": "keyword",
  37.      "fields": {
  38.       "analyzed": {
  39.        "type": "text",
  40.        "analyzer": "eventNameAnalyzer",
  41.        "search_analyzer": "eventNameAnalyzer"
  42.       }
  43.      }
  44.     },
  45.     "location": {
  46.      "type": "keyword"
  47.     },
  48.     "price": {
  49.      "type": "float"
  50.     }
  51.    }
  52.   }
  53.  }
  54. }
  55.  
  56. GET /events
  57.  
  58. POST events/_analyze
  59. {
  60.   "text": ["Elasticsearch is a POWERFUL search engine that makes it easy for us to search"],
  61.   "analyzer": "eventNameAnalyzer"
  62. }
  63.  
  64. PUT events/event/1
  65. {
  66.   "eventName": "How to process streams with Kafka Streams?",
  67.   "category": "Software Development",
  68.   "location": "Istanbul",
  69.   "price": 2300
  70. }
  71. PUT events/event/2
  72. {
  73.   "eventName": "Real Madrid vs Liverpool FC - UEFA Champions League 2017-18",
  74.   "category": "Football",
  75.   "location": "Kiev",
  76.   "price": 3450
  77. }
  78. PUT events/event/3
  79. {
  80.   "eventName": "Deep Learning Conference",
  81.   "category": "Software Development",
  82.   "location": "Istanbul",
  83.   "price": 300
  84. }
  85. PUT events/event/4
  86. {
  87.   "eventName": "Boston Celtics vs Philadelphia 76ers Basketball Playoff Game",
  88.   "location": "Boston",
  89.   "category": "Basketball",
  90.   "price": 450
  91. }
  92. PUT events/event/5
  93. {
  94.   "eventName": "Fenerbahce vs. Zalgiris Kaunas Euroleague Playoff Game",
  95.   "category": "Basketball",
  96.   "location": "Istanbul",
  97.   "price": 1000
  98. }
  99.  
  100. POST events/event/_search
  101. {
  102.   "query": {
  103.     "multi_match": {
  104.       "query": "boston basketball",
  105.       "fields": [
  106.         "eventName.analyzed",
  107.         "category.analyzed"
  108.       ],
  109.       "operator": "and",
  110.       "type": "best_fields"
  111.     }
  112.   }
  113. }
  114.  
  115. POST events/event/_search
  116. {
  117.   "size": 0,
  118.   "aggs": {
  119.     "Category Filter": {
  120.       "terms": {
  121.         "field": "category",
  122.         "size": 10
  123.       }
  124.     },
  125.     "Location Filter": {
  126.       "terms": {
  127.         "field": "location",
  128.         "size": 10
  129.       }
  130.     },
  131.     "Price Filter": {
  132.       "range": {
  133.         "field": "price",
  134.         "ranges": [
  135.           {
  136.             "from": 0,
  137.             "to": 1000
  138.           },
  139.           {
  140.             "from": 1000,
  141.             "to": 2000
  142.           },
  143.           {
  144.             "from": 2000,
  145.             "to": 4000
  146.           }
  147.         ]
  148.       }
  149.     }
  150.   }
  151. }
  152.  
  153. POST events/event/_search
  154. {
  155.   "query": {
  156.     "multi_match": {
  157.       "query": "game",
  158.       "fields": [
  159.         "eventName.analyzed",
  160.         "category.analyzed"
  161.       ],
  162.       "operator": "and",
  163.       "type": "best_fields"
  164.     }
  165.   },
  166.   "aggs": {
  167.     "Category Filter": {
  168.       "terms": {
  169.         "field": "category",
  170.         "size": 10
  171.       }
  172.     },
  173.     "Location Filter": {
  174.       "terms": {
  175.         "field": "location",
  176.         "size": 10
  177.       }
  178.     },
  179.     "Price Filter": {
  180.       "range": {
  181.         "field": "price",
  182.         "ranges": [
  183.           {
  184.             "from": 0,
  185.             "to": 1000
  186.           },
  187.           {
  188.             "from": 1000,
  189.             "to": 2000
  190.           },
  191.           {
  192.             "from": 2000,
  193.             "to": 3000
  194.           }
  195.         ]
  196.       }
  197.     }
  198.   }
  199. }
  200.  
  201. PUT shakespeare
  202. {
  203.   "settings": {
  204.     "analysis": {
  205.       "filter": {
  206.         "autocomplete_filter": {
  207.           "type": "edge_ngram",
  208.           "min_gram": "1",
  209.           "max_gram": "40"
  210.         }
  211.       },
  212.       "analyzer": {
  213.         "pk_custom_analyzer": {
  214.           "type":      "custom",
  215.           "tokenizer": "standard",
  216.           "char_filter": [
  217.             "html_strip"
  218.           ],
  219.           "filter": [
  220.             "lowercase"
  221.           ]
  222.         },
  223.         "autocomplete": {
  224.           "filter": ["lowercase", "autocomplete_filter"],
  225.           "type": "custom",
  226.           "tokenizer": "whitespace"
  227.         }
  228.       }
  229.     }
  230.   },
  231.   "mappings": {
  232.     "event": {
  233.       "properties": {
  234.         "speaker": {
  235.           "type": "keyword"
  236.         },
  237.         "play_name": {
  238.           "type": "text",
  239.           "fields": {
  240.             "analyzed": {
  241.               "type": "text",
  242.               "analyzer": "pk_custom_analyzer",
  243.               "search_analyzer": "pk_custom_analyzer"
  244.             }
  245.           }
  246.         },
  247.         "text_entry": {
  248.           "type": "text",
  249.           "fields": {
  250.             "analyzed": {
  251.               "type": "text",
  252.               "analyzer": "autocomplete",
  253.               "search_analyzer": "autocomplete"
  254.             }
  255.           }
  256.         },
  257.         "line_id": {
  258.           "type": "integer"
  259.         },
  260.         "speech_number": {
  261.           "type": "integer"
  262.         },
  263.         "line_number": {
  264.           "type": "keyword"
  265.         }
  266.       }
  267.     }
  268.   }
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement