tomaspet262

Untitled

Jun 21st, 2013
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 17.07 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. # DELETE
  4. curl -XDELETE 'http://localhost:9200/test'
  5. echo
  6.  
  7. # DEFINE
  8. curl -XPUT 'http://localhost:9200/test/posts/_mapping?pretty=1' -d '{
  9.    "posts" : {
  10.        "properties" : {
  11.            "section" : {
  12.              "type" : "string"
  13.            },
  14.            "category" : {
  15.              "type" : "string"
  16.            },
  17.            "title" : {
  18.              "type" : "string"
  19.            }
  20.        }
  21.    }
  22. }'
  23. echo
  24.  
  25. # INSERT
  26. curl localhost:9200/test/posts/1 -d '{section: "Bicycle", category: "Small", title: "Diamondback Grind-16"}'
  27. curl localhost:9200/test/posts/2 -d '{section: "Bicycle", category: "Big",   title: "Diamondback JrViper"}'
  28. curl localhost:9200/test/posts/3 -d '{section: "Bicycle", category: "Small", title: "2-Hip Cyclone Small"}'
  29. curl localhost:9200/test/posts/4 -d '{section: "Bicycle", category: "Big",   title: "2-Hip Bizzle"}'
  30. curl localhost:9200/test/posts/5 -d '{section: "Small",   category: "Small", title: "Toyota"}'
  31. curl localhost:9200/test/posts/6 -d '{section: "Car",     category: "Big",   title: "Subaru Impreza Small"}'
  32. curl localhost:9200/test/posts/7 -d '{section: "Small",   category: "Big",   title: "Toyota Corona MARK II"}'
  33. curl localhost:9200/test/posts/8 -d '{section: "Car",     category: "Small", title: "Hyundai Elantra"}'
  34. curl localhost:9200/test/posts/9 -d '{section: "Car",     category: "Big",   title: "Ford Maverick small"}'
  35. echo
  36.  
  37. # REFRESH
  38. curl -XPOST localhost:9200/test/_refresh
  39. echo
  40.  
  41. # SEARCH
  42. curl "localhost:9200/test/posts/_search?pretty=1" -d '{
  43.  "query" : {
  44.         "bool": {
  45.             "must": [
  46.                 {
  47.                     "multi_match": {
  48.                         "query": "small",
  49.                         "fields": ["section^100", "category^10", "title"],
  50.                         "use_dis_max": "false"
  51.                     }
  52.                 }
  53.             ]
  54.         }
  55.     },
  56.     "explain": "true"
  57. }'
  58.  
  59. # RESULTS
  60. {
  61.     "took": 73,
  62.     "timed_out": false,
  63.     "_shards": {
  64.         "total": 5,
  65.         "successful": 5,
  66.         "failed": 0
  67.     },
  68.     "hits": {
  69.         "total": 7,
  70.         "max_score": 0.32860997,
  71.         "hits": [{
  72.                 "_shard": 3,
  73.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  74.                 "_index": "test",
  75.                 "_type": "posts",
  76.                 "_id": "7",
  77.                 "_score": 0.32860997, "_source": {section: "Small", category: "Big", title: "Toyota Corona MARK II"},
  78.                 "_explanation": {
  79.                     "value": 0.32860997,
  80.                     "description": "product of:",
  81.                     "details": [{
  82.                             "value": 0.9858299,
  83.                             "description": "sum of:",
  84.                             "details": [{
  85.                                     "value": 0.9858299,
  86.                                     "description": "weight(section:small^100.0 in 1) [PerFieldSimilarity], result of:",
  87.                                     "details": [{
  88.                                             "value": 0.9858299,
  89.                                             "description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
  90.                                             "details": [{
  91.                                                     "value": 0.9858299,
  92.                                                     "description": "queryWeight, product of:",
  93.                                                     "details": [{
  94.                                                             "value": 100.0,
  95.                                                             "description": "boost"
  96.                                                         }, {
  97.                                                             "value": 1.0,
  98.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  99.                                                         }, {
  100.                                                             "value": 0.009858299,
  101.                                                             "description": "queryNorm"
  102.                                                         }]
  103.                                                 }, {
  104.                                                     "value": 1.0,
  105.                                                     "description": "fieldWeight in 1, product of:",
  106.                                                     "details": [{
  107.                                                             "value": 1.0,
  108.                                                             "description": "tf(freq=1.0), with freq of:",
  109.                                                             "details": [{
  110.                                                                     "value": 1.0,
  111.                                                                     "description": "termFreq=1.0"
  112.                                                                 }]
  113.                                                         }, {
  114.                                                             "value": 1.0,
  115.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  116.                                                         }, {
  117.                                                             "value": 1.0,
  118.                                                             "description": "fieldNorm(doc=1)"
  119.                                                         }]
  120.                                                 }]
  121.                                         }]
  122.                                 }]
  123.                         }, {
  124.                             "value": 0.33333334,
  125.                             "description": "coord(1/3)"
  126.                         }]
  127.                 }
  128.             }, {
  129.                 "_shard": 1,
  130.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  131.                 "_index": "test",
  132.                 "_type": "posts",
  133.                 "_id": "5",
  134.                 "_score": 0.22379102, "_source": {section: "Small", category: "Small", title: "Toyota"},
  135.                 "_explanation": {
  136.                     "value": 0.223791,
  137.                     "description": "product of:",
  138.                     "details": [{
  139.                             "value": 0.3356865,
  140.                             "description": "sum of:",
  141.                             "details": [{
  142.                                     "value": 0.030516956,
  143.                                     "description": "weight(category:small^10.0 in 0) [PerFieldSimilarity], result of:",
  144.                                     "details": [{
  145.                                             "value": 0.030516956,
  146.                                             "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
  147.                                             "details": [{
  148.                                                     "value": 0.099451445,
  149.                                                     "description": "queryWeight, product of:",
  150.                                                     "details": [{
  151.                                                             "value": 10.0,
  152.                                                             "description": "boost"
  153.                                                         }, {
  154.                                                             "value": 0.30685282,
  155.                                                             "description": "idf(docFreq=1, maxDocs=1)"
  156.                                                         }, {
  157.                                                             "value": 0.032410145,
  158.                                                             "description": "queryNorm"
  159.                                                         }]
  160.                                                 }, {
  161.                                                     "value": 0.30685282,
  162.                                                     "description": "fieldWeight in 0, product of:",
  163.                                                     "details": [{
  164.                                                             "value": 1.0,
  165.                                                             "description": "tf(freq=1.0), with freq of:",
  166.                                                             "details": [{
  167.                                                                     "value": 1.0,
  168.                                                                     "description": "termFreq=1.0"
  169.                                                                 }]
  170.                                                         }, {
  171.                                                             "value": 0.30685282,
  172.                                                             "description": "idf(docFreq=1, maxDocs=1)"
  173.                                                         }, {
  174.                                                             "value": 1.0,
  175.                                                             "description": "fieldNorm(doc=0)"
  176.                                                         }]
  177.                                                 }]
  178.                                         }]
  179.                                 }, {
  180.                                     "value": 0.30516955,
  181.                                     "description": "weight(section:small^100.0 in 0) [PerFieldSimilarity], result of:",
  182.                                     "details": [{
  183.                                             "value": 0.30516955,
  184.                                             "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
  185.                                             "details": [{
  186.                                                     "value": 0.9945144,
  187.                                                     "description": "queryWeight, product of:",
  188.                                                     "details": [{
  189.                                                             "value": 100.0,
  190.                                                             "description": "boost"
  191.                                                         }, {
  192.                                                             "value": 0.30685282,
  193.                                                             "description": "idf(docFreq=1, maxDocs=1)"
  194.                                                         }, {
  195.                                                             "value": 0.032410145,
  196.                                                             "description": "queryNorm"
  197.                                                         }]
  198.                                                 }, {
  199.                                                     "value": 0.30685282,
  200.                                                     "description": "fieldWeight in 0, product of:",
  201.                                                     "details": [{
  202.                                                             "value": 1.0,
  203.                                                             "description": "tf(freq=1.0), with freq of:",
  204.                                                             "details": [{
  205.                                                                     "value": 1.0,
  206.                                                                     "description": "termFreq=1.0"
  207.                                                                 }]
  208.                                                         }, {
  209.                                                             "value": 0.30685282,
  210.                                                             "description": "idf(docFreq=1, maxDocs=1)"
  211.                                                         }, {
  212.                                                             "value": 1.0,
  213.                                                             "description": "fieldNorm(doc=0)"
  214.                                                         }]
  215.                                                 }]
  216.                                         }]
  217.                                 }]
  218.                         }, {
  219.                             "value": 0.6666667,
  220.                             "description": "coord(2/3)"
  221.                         }]
  222.                 }
  223.             }, {
  224.                 "_shard": 2,
  225.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  226.                 "_index": "test",
  227.                 "_type": "posts",
  228.                 "_id": "1",
  229.                 "_score": 0.019652616, "_source": {section: "Bicycle", category: "Small", title: "Diamondback Grind-16"},
  230.                 "_explanation": {
  231.                     "value": 0.019652616,
  232.                     "description": "product of:",
  233.                     "details": [{
  234.                             "value": 0.058957845,
  235.                             "description": "sum of:",
  236.                             "details": [{
  237.                                     "value": 0.058957845,
  238.                                     "description": "weight(category:small^10.0 in 0) [PerFieldSimilarity], result of:",
  239.                                     "details": [{
  240.                                             "value": 0.058957845,
  241.                                             "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
  242.                                             "details": [{
  243.                                                     "value": 0.058957845,
  244.                                                     "description": "queryWeight, product of:",
  245.                                                     "details": [{
  246.                                                             "value": 10.0,
  247.                                                             "description": "boost"
  248.                                                         }, {
  249.                                                             "value": 1.0,
  250.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  251.                                                         }, {
  252.                                                             "value": 0.0058957846,
  253.                                                             "description": "queryNorm"
  254.                                                         }]
  255.                                                 }, {
  256.                                                     "value": 1.0,
  257.                                                     "description": "fieldWeight in 0, product of:",
  258.                                                     "details": [{
  259.                                                             "value": 1.0,
  260.                                                             "description": "tf(freq=1.0), with freq of:",
  261.                                                             "details": [{
  262.                                                                     "value": 1.0,
  263.                                                                     "description": "termFreq=1.0"
  264.                                                                 }]
  265.                                                         }, {
  266.                                                             "value": 1.0,
  267.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  268.                                                         }, {
  269.                                                             "value": 1.0,
  270.                                                             "description": "fieldNorm(doc=0)"
  271.                                                         }]
  272.                                                 }]
  273.                                         }]
  274.                                 }]
  275.                         }, {
  276.                             "value": 0.33333334,
  277.                             "description": "coord(1/3)"
  278.                         }]
  279.                 }
  280.             }, {
  281.                 "_shard": 4,
  282.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  283.                 "_index": "test",
  284.                 "_type": "posts",
  285.                 "_id": "3",
  286.                 "_score": 0.015876401, "_source": {section: "Bicycle", category: "Small", title: "2-Hip Cyclone Small"},
  287.                 "_explanation": {
  288.                     "value": 0.015876401,
  289.                     "description": "product of:",
  290.                     "details": [{
  291.                             "value": 0.0238146,
  292.                             "description": "sum of:",
  293.                             "details": [{
  294.                                     "value": 0.0029512104,
  295.                                     "description": "weight(title:small in 0) [PerFieldSimilarity], result of:",
  296.                                     "details": [{
  297.                                             "value": 0.0029512104,
  298.                                             "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
  299.                                             "details": [{
  300.                                                     "value": 0.0059024207,
  301.                                                     "description": "queryWeight, product of:",
  302.                                                     "details": [{
  303.                                                             "value": 1.0,
  304.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  305.                                                         }, {
  306.                                                             "value": 0.0059024207,
  307.                                                             "description": "queryNorm"
  308.                                                         }]
  309.                                                 }, {
  310.                                                     "value": 0.5,
  311.                                                     "description": "fieldWeight in 0, product of:",
  312.                                                     "details": [{
  313.                                                             "value": 1.0,
  314.                                                             "description": "tf(freq=1.0), with freq of:",
  315.                                                             "details": [{
  316.                                                                     "value": 1.0,
  317.                                                                     "description": "termFreq=1.0"
  318.                                                                 }]
  319.                                                         }, {
  320.                                                             "value": 1.0,
  321.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  322.                                                         }, {
  323.                                                             "value": 0.5,
  324.                                                             "description": "fieldNorm(doc=0)"
  325.                                                         }]
  326.                                                 }]
  327.                                         }]
  328.                                 }, {
  329.                                     "value": 0.02086339,
  330.                                     "description": "weight(category:small^10.0 in 0) [PerFieldSimilarity], result of:",
  331.                                     "details": [{
  332.                                             "value": 0.02086339,
  333.                                             "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
  334.                                             "details": [{
  335.                                                     "value": 0.03509195,
  336.                                                     "description": "queryWeight, product of:",
  337.                                                     "details": [{
  338.                                                             "value": 10.0,
  339.                                                             "description": "boost"
  340.                                                         }, {
  341.                                                             "value": 0.5945349,
  342.                                                             "description": "idf(docFreq=2, maxDocs=2)"
  343.                                                         }, {
  344.                                                             "value": 0.0059024207,
  345.                                                             "description": "queryNorm"
  346.                                                         }]
  347.                                                 }, {
  348.                                                     "value": 0.5945349,
  349.                                                     "description": "fieldWeight in 0, product of:",
  350.                                                     "details": [{
  351.                                                             "value": 1.0,
  352.                                                             "description": "tf(freq=1.0), with freq of:",
  353.                                                             "details": [{
  354.                                                                     "value": 1.0,
  355.                                                                     "description": "termFreq=1.0"
  356.                                                                 }]
  357.                                                         }, {
  358.                                                             "value": 0.5945349,
  359.                                                             "description": "idf(docFreq=2, maxDocs=2)"
  360.                                                         }, {
  361.                                                             "value": 1.0,
  362.                                                             "description": "fieldNorm(doc=0)"
  363.                                                         }]
  364.                                                 }]
  365.                                         }]
  366.                                 }]
  367.                         }, {
  368.                             "value": 0.6666667,
  369.                             "description": "coord(2/3)"
  370.                         }]
  371.                 }
  372.             }, {
  373.                 "_shard": 4,
  374.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  375.                 "_index": "test",
  376.                 "_type": "posts",
  377.                 "_id": "8",
  378.                 "_score": 0.006954463, "_source": {section: "Car", category: "Small", title: "Hyundai Elantra"},
  379.                 "_explanation": {
  380.                     "value": 0.006954463,
  381.                     "description": "product of:",
  382.                     "details": [{
  383.                             "value": 0.02086339,
  384.                             "description": "sum of:",
  385.                             "details": [{
  386.                                     "value": 0.02086339,
  387.                                     "description": "weight(category:small^10.0 in 1) [PerFieldSimilarity], result of:",
  388.                                     "details": [{
  389.                                             "value": 0.02086339,
  390.                                             "description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
  391.                                             "details": [{
  392.                                                     "value": 0.03509195,
  393.                                                     "description": "queryWeight, product of:",
  394.                                                     "details": [{
  395.                                                             "value": 10.0,
  396.                                                             "description": "boost"
  397.                                                         }, {
  398.                                                             "value": 0.5945349,
  399.                                                             "description": "idf(docFreq=2, maxDocs=2)"
  400.                                                         }, {
  401.                                                             "value": 0.0059024207,
  402.                                                             "description": "queryNorm"
  403.                                                         }]
  404.                                                 }, {
  405.                                                     "value": 0.5945349,
  406.                                                     "description": "fieldWeight in 1, product of:",
  407.                                                     "details": [{
  408.                                                             "value": 1.0,
  409.                                                             "description": "tf(freq=1.0), with freq of:",
  410.                                                             "details": [{
  411.                                                                     "value": 1.0,
  412.                                                                     "description": "termFreq=1.0"
  413.                                                                 }]
  414.                                                         }, {
  415.                                                             "value": 0.5945349,
  416.                                                             "description": "idf(docFreq=2, maxDocs=2)"
  417.                                                         }, {
  418.                                                             "value": 1.0,
  419.                                                             "description": "fieldNorm(doc=1)"
  420.                                                         }]
  421.                                                 }]
  422.                                         }]
  423.                                 }]
  424.                         }, {
  425.                             "value": 0.33333334,
  426.                             "description": "coord(1/3)"
  427.                         }]
  428.                 }
  429.             }, {
  430.                 "_shard": 2,
  431.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  432.                 "_index": "test",
  433.                 "_type": "posts",
  434.                 "_id": "6",
  435.                 "_score": 9.826308E-4, "_source": {section: "Car", category: "Big", title: "Subaru Impreza Small"},
  436.                 "_explanation": {
  437.                     "value": 9.826308E-4,
  438.                     "description": "product of:",
  439.                     "details": [{
  440.                             "value": 0.0029478923,
  441.                             "description": "sum of:",
  442.                             "details": [{
  443.                                     "value": 0.0029478923,
  444.                                     "description": "weight(title:small in 1) [PerFieldSimilarity], result of:",
  445.                                     "details": [{
  446.                                             "value": 0.0029478923,
  447.                                             "description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
  448.                                             "details": [{
  449.                                                     "value": 0.0058957846,
  450.                                                     "description": "queryWeight, product of:",
  451.                                                     "details": [{
  452.                                                             "value": 1.0,
  453.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  454.                                                         }, {
  455.                                                             "value": 0.0058957846,
  456.                                                             "description": "queryNorm"
  457.                                                         }]
  458.                                                 }, {
  459.                                                     "value": 0.5,
  460.                                                     "description": "fieldWeight in 1, product of:",
  461.                                                     "details": [{
  462.                                                             "value": 1.0,
  463.                                                             "description": "tf(freq=1.0), with freq of:",
  464.                                                             "details": [{
  465.                                                                     "value": 1.0,
  466.                                                                     "description": "termFreq=1.0"
  467.                                                                 }]
  468.                                                         }, {
  469.                                                             "value": 1.0,
  470.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  471.                                                         }, {
  472.                                                             "value": 0.5,
  473.                                                             "description": "fieldNorm(doc=1)"
  474.                                                         }]
  475.                                                 }]
  476.                                         }]
  477.                                 }]
  478.                         }, {
  479.                             "value": 0.33333334,
  480.                             "description": "coord(1/3)"
  481.                         }]
  482.                 }
  483.             }, {
  484.                 "_shard": 0,
  485.                 "_node": "orjzC90ISLKZY7Zq4edY3g",
  486.                 "_index": "test",
  487.                 "_type": "posts",
  488.                 "_id": "9",
  489.                 "_score": 9.794582E-4, "_source": {section: "Car", category: "Big", title: "Ford Maverick small"},
  490.                 "_explanation": {
  491.                     "value": 9.794582E-4,
  492.                     "description": "product of:",
  493.                     "details": [{
  494.                             "value": 0.0029383744,
  495.                             "description": "sum of:",
  496.                             "details": [{
  497.                                     "value": 0.0029383744,
  498.                                     "description": "weight(title:small in 1) [PerFieldSimilarity], result of:",
  499.                                     "details": [{
  500.                                             "value": 0.0029383744,
  501.                                             "description": "score(doc=1,freq=1.0 = termFreq=1.0\n), product of:",
  502.                                             "details": [{
  503.                                                     "value": 0.005876749,
  504.                                                     "description": "queryWeight, product of:",
  505.                                                     "details": [{
  506.                                                             "value": 1.0,
  507.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  508.                                                         }, {
  509.                                                             "value": 0.005876749,
  510.                                                             "description": "queryNorm"
  511.                                                         }]
  512.                                                 }, {
  513.                                                     "value": 0.5,
  514.                                                     "description": "fieldWeight in 1, product of:",
  515.                                                     "details": [{
  516.                                                             "value": 1.0,
  517.                                                             "description": "tf(freq=1.0), with freq of:",
  518.                                                             "details": [{
  519.                                                                     "value": 1.0,
  520.                                                                     "description": "termFreq=1.0"
  521.                                                                 }]
  522.                                                         }, {
  523.                                                             "value": 1.0,
  524.                                                             "description": "idf(docFreq=1, maxDocs=2)"
  525.                                                         }, {
  526.                                                             "value": 0.5,
  527.                                                             "description": "fieldNorm(doc=1)"
  528.                                                         }]
  529.                                                 }]
  530.                                         }]
  531.                                 }]
  532.                         }, {
  533.                             "value": 0.33333334,
  534.                             "description": "coord(1/3)"
  535.                         }]
  536.                 }
  537.             }]
  538.     }
  539. }
Advertisement
Add Comment
Please, Sign In to add comment