2arunpmohan
9/8/2016 - 8:40 AM

bash scripts for "suggest" mapping example of suggest implementation

bash scripts for "suggest" mapping example of suggest implementation

#!/bin/bash

if [ -z $1 ] ; then
    echo "Please enter hostname"
    exit
fi

hostname=$1

curl -XDELETE "http://$hostname:9200/suggest-simple"
echo
curl -X PUT "http://$hostname:9200/suggest-simple" -d '{
  "settings": {
    "index": {
      "number_of_replicas": "1",
      "number_of_shards": "5"
    }
  },
  "mappings": {
    "logs": {
      "properties": {
        "name": {
          "type": "string"
        },
        "domain": {
          "type": "string"
        },
        "postcode": {
          "type": "string"
        },
        "nameSuggest": {
          "type": "completion",
          "context": {
            "domain": {
              "type": "category"
            },
            "postcode": {
              "type": "category"
            }
          }
        }
      }
    }
  }
}'
#!/bin/bash

if [ -z $1 ] ; then
    echo "Please enter hostname"
    exit
fi

hostname=$1

curl -XDELETE "http://$hostname:9200/suggest-new"
echo
curl -X PUT "http://$hostname:9200/suggest-new" -d '{
  "mappings": {
    "suggest": {
      "properties": {
        "store_suggest": {
          "context": {
            "mallIdContext": {
              "path": "mallId",
              "default": [
                "no mall Id"
              ] 
            }
          },
          "type": "completion"
        },        
        "movie_suggest": {
          "context": {
            "mallIdContext": {
              "path": "mallId",
              "default": [
                "no mall Id"
              ] 
            }
          },
          "type": "completion"
        }, 
        "pt_suggest": {
          "context": {
            "mallIdContext": {
              "path": "mallId",
              "default": [
                "no mall Id"
              ] 
            }
          },
          "type": "completion"
        },
        "brand_suggest": {
          "context": {
            "mallIdContext": {
              "path": "mallId",
              "default": [
                "no mall Id"
              ] 
            }
          },
          "type": "completion"
        },
        "mallId": {
          "type": "long"
        },
        "source": {
          "type": "string"
        },
        "title": {
          "type": "string"
        }
      }
    }
  }
}'