Skip to main content

elastic search all queries

PUT twitter/_doc/1
{
    "user" : "kimchy",
    "message" : "trying out Elasticsearch having running all the way goes down sizing are is the"
}

PUT /my_index1
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my": {
          "type": "standard",
          "stopwords": [ "is", "having" ]
        }
      }
    }
  }
}



GET /_search?q=having   

GET /_analyze
{
  "analyzer": "standard",
  "text": "trying out Elasticsearch having running all the way goes down sizing are is the"
}

GET /_analyze?tokenizer=whitespace
{"You're the 1st runner home!"}

POST _analyze
{
  "analyzer": "my_analyzer",
  "text":     "The quick brown fox."
}


PUT /my_index
{
  "mappings": {
    "blog": {
      "properties": {
        "title": {
          "type": "text",
          "fields": {
            "english": {
              "type":     "text",
              "analyzer": "english"
            }
          }
        }
      }
    }
  }
}


GET my_index1/_analyze
{
  "analyzer": "my",
  "text":     "trying out Elasticsearch having running all the way goes down sizing are is the"
}




PUT /my_index/blog/1
{ "title": "I'm happy for this fox" }

PUT /my_index/blog/2
{ "title": "i love new york the ny city" }

GET /_search
{
  "query": {
    "multi_match": {
      "type":     "most_fields",
      "query":    "not happy foxes",
      "fields": [ "title", "title.english" ]
    }
  }
}

Get allvideos/_search?q=knowledge



POST /allvideos/_search
{
    "query": {
        "match" : {
            "script" : "knowledge"
        }
    },
    "size": 2,
    "from": 0,
    "_source": [ "title", "script" , "description", "videoId"]
}




POST /individualvideos/_search
{
   
  "query": {
    "bool": {
      "should": [
        { "match": { "dialog":  "knowledge" }},
        { "match": { "videoId": "-X21K4ixPH8"   }}
      ]
    }
  }
},
    "size": 4,
    "from": 0,
    "_source": [ "dialog" ]
}

PUT /my_index
{
  "settings": {
    "analysis": {
      "filter": {
        "my_synonym_filter": {
          "type": "synonym",
          "synonyms": [
            "british,english",
            "queen,monarch"
          ]
        }
      },
      "analyzer": {
        "my_synonyms": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "my_synonym_filter"
          ]
        }
      }
    }
  }
}

GET /my_index/_analyze
{
  "analyzer" : "my_synonyms",
  "text" : "Elizabeth is the English queen"
}

"settings": {
        "analysis": {
            "analyzer": {
                "syn_text": {
                    "tokenizer": "standard",
                    "filter": ["health_synonym"]
                }
            },
            "filter": {
                "health_synonym": {
                    "type": "synonym",
                    "synonyms": ["heart attack, myocardial infarction, mi, cardiac arrest, heartattack"]
                }
            }
        }       
    }
   
   
PUT /test_index
{
    "settings": {
        "index" : {
            "analysis" : {
                "filter" : {
                    "synonym" : {
                        "type" : "synonym",
                        "synonyms_path" : "analysis/synonym.txt",
                        "tokenizer" : "whitespace"
                    }
                },
                "analyzer" : {
                    "synonym" : {
                        "tokenizer" : "whitespace",
                        "filter" : ["synonym"]
                    }
                }
            }
        }
    }
}


GET /_search
{
   "query": {
       "query_string" : {
           "default_field": "title",
           "query" : "ny city",
           "auto_generate_synonyms_phrase_query" : false
       }
   }
}

PUT /my_index3
{
  "settings": {
    "analysis": {
      "filter": {
        "my_synonym_filter": {
          "type": "synonym",
          "synonyms": [
            "usa,united states,u s a,united states of america"
          ]
        }
      },
      "analyzer": {
        "my_synonyms": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "my_synonym_filter"
          ]
        }
      }
    }
  }
}




PUT twitter/_doc/1
{
    "user" : "usa",
    "message" : "trying out Elasticsearch having running all the way usa goes down sizing are is the"
}



PUT /my_index3
{
  "settings": {
    "analysis":{
    "analyzer":{
        "synonyms":{
            "filter":[
                "lowercase",
                "synonym_filter"
            ],
        "tokenizer": "standard"
    }
},
"filter": {
"synonym_filter": {
"type": "synonym",
"synonyms": [
"United States,US,USA,USA=>usa",
"Alabama,Al,Ala,Ala",
"Alaska,Ak,Alas,Alas",
"Arizona,Az,Ariz",
"Arkansas,Ar,Ark",
"California,Ca,Calif,Cal",
"Colorado,Co,Colo,Col",
"Connecticut,Ct,Conn",
"Deleware,De,Del",
"District of Columbia,Dc,Wash Dc,Washington Dc=>Dc",
"Florida,Fl,Fla,Flor",
"Georgia,Ga",
"Hawaii,Hi",
"Idaho,Id,Ida",
"Illinois,Il,Ill,Ills",
"Indiana,In,Ind",
"Iowa,Ia,Ioa",
"Kansas,Kans,Kan,Ks",
"Kentucky,Ky,Ken,Kent",
"Louisiana,La",
"Maine,Me",
"Maryland,Md",
"Massachusetts,Ma,Mass",
"Michigan,Mi,Mich",
"Minnesota,Mn,Minn",
"Mississippi,Ms,Miss",
"Missouri,Mo",
"Montana,Mt,Mont",
"Nebraska,Ne,Neb,Nebr",
"Nevada,Nv,Nev",
"New Hampshire,Nh=>Nh",
"New Jersey,Nj=>Nj",
"New Mexico,Nm,N Mex,New M=>Nm",
"New York,Ny=>Ny",
"North Carolina,Nc,N Car=>Nc",
"North Dakota,Nd,N Dak, NoDak=>Nd",
"Ohio,Oh,O",
"Oklahoma,Ok,Okla",
"Oregon,Or,Oreg,Ore",
"Pennsylvania,Pa,Penn,Penna",
"Rhode Island,Ri,Ri & PP,R Isl=>Ri",
"South Carolina,Sc,S Car=>Sc",
"South Dakota,Sd,S Dak,SoDak=>Sd",
"Tennessee,Te,Tenn",
"Texas,Tx,Tex",
"Utah,Ut",
"Vermont,Vt",
"Virginia,Va,Virg",
"Washington,Wa,Wash,Wn",
"West Virginia,Wv,W Va, W Virg=>Wv",
"Wisconsin,Wi,Wis,Wisc",
"Wyomin,Wi,Wyo"
]
}
}
  }
}
}



GET my_index3/_search
{
  "query": {
    "match": {
      "text": {
        "query": "wyo",
         "analyzer": "synonyms"
      }
    }
  }
}


PUT my_index3/_doc/2
{
  "text": "wi sdfs"
}



PUT /my_index/blog/1
{ "title": "I'm happy for this fox" }


GET /_search
{
  "query": {
    "match" : {
    "location.region.name" : {
        "query" : "Massachusetts",
     
        "analyzer" : "synonyms"
    }
}
  }
}

POST /twitte/ASC
{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}




PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_custom_analyzer": {
          "type":      "custom",
          "tokenizer": "standard",
          "char_filter": [
            "html_strip"
          ],
          "filter": [
            "lowercase",
            "asciifolding"
          ]
        }
      }
    }
  }
}


POST my_index/_analyze
{
  "analyzer": "my_custom_analyzer",
  "text": "Is this <b>déjà vu</b>?"
}

PUT my_index
{
  "settings": {
    "analysis": {
      "filter": {
        "autocomplete_filter": {
          "type": "edge_ngram",
          "min_gram": 1,
          "max_gram": 20
        }
      },
      "analyzer": {
        "autocomplete": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "autocomplete_filter"
          ]
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "properties": {
        "text": {
          "type": "text",
          "analyzer": "autocomplete",
          "search_analyzer": "standard"
        }
      }
    }
  }
}

PUT my_index/_doc/1
{
  "text": "Quick Brown Fox"
}

GET my_index/_search
{
  "query": {
    "match": {
      "text": {
        "query": "Quick Br",
        "operator": "and"
      }
    }
  }
}


PUT /allvideos
{
  "settings": {
    "analysis":{
    "analyzer":{
        "synonyms":{
            "filter":[
                "lowercase",
                "synonym_filter"
            ],
        "tokenizer": "standard"
    }
},
"filter": {
 "synonym_filter": {
 "type": "synonym",
 "synonyms_path" : "analysis/synonym.txt"
 }
 }
  }
}
}


GET allvideos/_search
{
  "query": {
    "match": {
      "script": "love"
    }
  }
}


GET  allvideos/_search?q=love


Get allvideos/_search?q=knowledge


GET /allvideos/_mapping



PUT /allvideos
{
  "settings": {
    "analysis":{
    "analyzer":{
        "synonyms":{
            "filter":[
                "lowercase",
                "synonym_filter"
            ],
        "tokenizer": "standard"
    }
},
"filter": {
 "synonym_filter": {
 "type": "synonym",
 "synonyms": [
 "United States,US,USA,USA=>usa",
 "Alabama,Al,Ala,Ala",
 "Alaska,Ak,Alas,Alas",
 "Arizona,Az,Ariz",
 "Arkansas,Ar,Ark",
 "California,Ca,Calif,Cal",
 "Colorado,Co,Colo,Col",
 "Connecticut,Ct,Conn",
 "Deleware,De,Del",
 "District of Columbia,Dc,Wash Dc,Washington Dc=>Dc",
 "Florida,Fl,Fla,Flor",
 "Georgia,Ga",
 "Hawaii,Hi",
 "Idaho,Id,Ida",
 "Illinois,Il,Ill,Ills",
 "Indiana,In,Ind",
 "Iowa,Ia,Ioa",
 "Kansas,Kans,Kan,Ks",
 "Kentucky,Ky,Ken,Kent",
 "Louisiana,La",
 "Maine,Me",
 "Maryland,Md",
 "Massachusetts,Ma,Mass",
 "Michigan,Mi,Mich",
 "Minnesota,Mn,Minn",
 "Mississippi,Ms,Miss",
 "Missouri,Mo",
 "Montana,Mt,Mont",
 "Nebraska,Ne,Neb,Nebr",
 "Nevada,Nv,Nev",
 "New Hampshire,Nh=>Nh",
 "New Jersey,Nj=>Nj",
 "New Mexico,Nm,N Mex,New M=>Nm",
 "New York,Ny=>Ny",
 "North Carolina,Nc,N Car=>Nc",
 "North Dakota,Nd,N Dak, NoDak=>Nd",
 "Ohio,Oh,O",
 "Oklahoma,Ok,Okla",
 "Oregon,Or,Oreg,Ore",
 "Pennsylvania,Pa,Penn,Penna",
 "Rhode Island,Ri,Ri & PP,R Isl=>Ri",
 "South Carolina,Sc,S Car=>Sc",
 "South Dakota,Sd,S Dak,SoDak=>Sd",
 "Tennessee,Te,Tenn",
 "Texas,Tx,Tex",
 "Utah,Ut",
 "Vermont,Vt",
 "Virginia,Va,Virg",
 "Washington,Wa,Wash,Wn",
 "West Virginia,Wv,W Va, W Virg=>Wv",
 "Wisconsin,Wi,Wis,Wisc",
 "Wyomin,Wi,Wyo"
 ]
 }
 }
  }
}
}




GET allvideos/_search
{
    "query": {
        "common": {
            "description": {
                "query": "deal fear^2",
                "cutoff_frequency": 0.001
            }
        }
    }
}


GET allvideos/_search
{
   "query": {
      "match": {
         "description": {
            "query": "deal fear is this that what",
            "cutoff_frequency": 0.001
         }
      }
   }
}


GET /_search
{
    "query": {
        "query_string": {
            "query": "love moves the world"
           
        }
    }
}

Get allvideos/_search?q=fright


PUT /allvideos2
{
  "analysis": {
    "filter": {
      "synonym": {
        "type": "synonym",
        "synonyms": [
          "small, tiny"
        ]
      }
    },
    "analyzer": {
      "synonymAnalyzer": {
        "type": "custom",
        "tokenizer": "standard",
        "filter": [
          "lowercase",
          "synonym"
        ]
      }
    }
  }
}

PUT /allvideos2
{
    "settings": {
        "index" : {
            "analysis" : {
                "filter" : {
                    "synonym" : {
                        "type" : "synonym",
                        "format" : "wordnet",
                        "synonyms" : [
                            "s(100000001,1,'abstain',v,1,0).",
                            "s(100000001,2,'refrain',v,1,0).",
                            "s(100000001,3,'desist',v,1,0)."
                        ]
                    }
                }
            }
        }
    }
}


PUT /allvideos
{
  "settings": {
    "analysis":{
    "analyzer":{
        "synonyms":{
            "filter":[
                "lowercase",
                "synonym_filter"
            ],
        "tokenizer": "standard"
    }
},
"filter": {
 "synonym_filter": {
 "type": "synonym",
 "format" : "wordnet",
 "synonyms_path" : "analysis/wn_s.pl"

 }
 }
  }
}
}


PUT /individualvideos
{
  "settings": {
    "analysis":{
    "analyzer":{
        "synonyms":{
            "filter":[
                "lowercase",
                "synonym_filter"
            ],
        "tokenizer": "standard"
    }
},
"filter": {
 "synonym_filter": {
 "type": "synonym",
 "format" : "wordnet",
 "synonyms_path" : "analysis/wn_s.pl"

 }
 }
  }
}
}



POST allvideos/_analyze
{
  "analyzer": "synonyms",
  "text":     "feeling good"
}

GET allvideos/_search
{
  "query": {
    "match": {
      "description": {
        "query": "tell me about relationship",
         "analyzer": "synonyms"
      }
    }
  }
}

GET individualvideos/_search
{
  "from" : 0, "size" : 3,
  "query": {
    "match": {
      "dialog": {
        "query": "lonesome",
         "analyzer": "synonyms"
      }
    }
  }
}



GET allvideos/_search
{
 
  "query": {
    "match": {
      "script": {
        "query": "shiva",
         "analyzer": "synonyms"
      }
    }
  }
}

Get allvideos/_search?q="maya"


Get individualvideos/_search
{
"query": {
          "bool": {
              "should": [{
                      "match": {
                          "dialog": "shiva"
                      }
                  },
                  {
                      "match": {
                          "videoId": "M0HuLasTGjc"
                      }
                  }
              ]
          }
      }
      }
     
     
POST  /individualvideos/_search
{
    "query": {
        "bool": {
            "should": {
                "bool" : { "should": [
                      { "match": { "dialog": "tell me about maya" }}
                      ] }
            },
            "must": { "match": { "videoId": "y0G2tYR6" }}
           
        }
    }
}


     
POST  /individualvideos/_search
{
    "query": {
        "bool": {
            "should": {
                "bool" : { "should": [
                      { "match": { "dialog": {
                          "query": "make love"
                           "query": query,
                        "analyzer": "synonyms"
                      } }}
                      ] }
            },
            "must": { "match": { "videoId": "lOOeHa6PGNU" }}
           
        }
    }
}

Get allvideos/_search?q="secrets"

GET allvideos/_search
{
    "query": {
        "query_string": {
            "query": "secrets of management"
           
        }
    }
}



POST allvideos/_search
{
    "query": {
        "multi_match" : {
            "query" : "secrets of management",
            "fields": ["title^23", "script", "description^2"]
        }
    },
    "_source": ["title", "summary", "publish_date"]
}

PUT index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "english_exact": {
          "tokenizer": "standard",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  },
  "mappings": {
    "_doc": {
      "properties": {
        "body": {
          "type": "text",
          "analyzer": "english",
          "fields": {
            "exact": {
              "type": "text",
              "analyzer": "english_exact"
            }
          }
        }
      }
    }
  }
}


PUT index/_doc/1
{
  "body": "Ski resort"
}

PUT index/_doc/2
{
  "body": "A pair of skis"
}

PUT index/_doc/3
{
  "body": "this universe it very good"
}

GET index/_search
{
  "query": {
    "simple_query_string": {
      "fields": [ "body" ],
      "query": "ski"
    }
  }
}

GET index/_search
{
  "query": {
    "simple_query_string": {
      "fields": [ "body.exact" ],
      "query": "ski"
    }
  }
}


GET index/_search
{
   "query": {
        "query_string": {
            "query": "university"
           
        }
    }
}

PUT index2/_doc/3
{
  "body": "this universe it very good"
}

GET index2/_search
{
   "query": {
        "query_string": {
            "query": "university"
           
        }
    }
}

DELETE /allvideos

DELETE /individualvideos

DELETE /hindiallvideos

DELETE /hindiindividualvideos

DELETE /modifiedhindiindividualvideos

DELETE /modifiedhindiallvideos

DELETE /tedall

DELETE /tedindi

DELETE  /arnaball

DELETE /arnabindividual


PUT index2/_doc/3
{
  "body": "मेरा गुरु सबसे अच्छा है"
}


PUT /index2/_doc/_mapping
{
  "doc": {
    "properties": {
      "title": {
        "type": "string",
        "fields": {
          "exact": {
            "type": "string",
            "index": "not_analyzed"
          },         
          "synonym": {
            "type": "string",
            "index": "analyzed",
            "analyzer": "synonym_analyzer"
          },
          "stemmed": {
            "type": "string",
            "index": "analyzed",
            "analyzer": "stemming_analyzer"
          }
        }
      }
    }
  }
}


PUT /my_index3/blog/1
{ "title": "I'm happy for this fox" }


PUT /my_index3/blog/_mapping
{
  "blog": {
    "properties": {
      "title": {
        "type": "text",
        "fields": {
          "exact": {
            "type": "keyword",
            "index": "not_analyzed"
          },         
          "synonym": {
            "type": "keyword",
            "index": "analyzed",
            "analyzer": "synonym_analyzer"
          },
          "stemmed": {
            "type": "keyword",
            "index": "analyzed",
            "analyzer": "stemming_analyzer"
          }
        }
      }
    }
  }
}


PUT my_index4
{
   "settings": {
    "analysis": {
      "filter": {
        "arabic_stop": {
          "type":       "stop",
          "stopwords":  "_arabic_"
        },
        "arabic_keywords": {
          "type":       "keyword_marker",
          "keywords":   ["مثال"]
        },
        "arabic_stemmer": {
          "type":       "stemmer",
          "language":   "arabic"
        }
      },
      "analyzer": {
        "stemming_analyzer": {
          "tokenizer":  "standard",
          "filter": [
            "lowercase",
            "arabic_stop",
            "arabic_normalization",
            "arabic_keywords",
            "arabic_stemmer"
          ]
        },
        "synonym_analyzer": {
          "tokenizer":  "standard",
          "filter": [
            "lowercase",
            "arabic_stop",
            "arabic_normalization",
            "arabic_keywords",
            "arabic_stemmer"
          ]
        }
       
      }
    }
  },
  "mappings":{
    "blog":{
          "properties": {
    "title": {
        "type": "text",
        "fields": {
          "exact": {
            "type": "text"
           
          },         
          "synonym": {
            "type": "text",
           
            "analyzer": "synonym_analyzer"
          },
          "stemmed": {
            "type": "text",
           
            "analyzer": "stemming_analyzer"
          }
        }
      }
    }
    }

  }
}





























Comments

Popular posts from this blog

opening multiple ports tunnels ngrok in ubuntu

Location for the config yml file /home/example/.ngrok2/ngrok.yml content of config file authtoken: 4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p tunnels: app-foo: addr: 80 proto: http host_header: app-foo.dev app-bar: addr: 80 proto: http host_header: app-bar.dev how to start ngrok with considering the config file: ngrok start --all

rename field in elastic Search

https://qiita.com/tkprof/items/e50368eb1473497a16d0 How to Rename an Elasticsearch field from columns: - {name: xxx, type: double} to columns: - {name: yyy, type: double} Pipeline API and reindex create a new Pipeline API : Rename Processor PUT _ingest/pipeline/pipeline_rename_xxx { "description" : "rename xxx", "processors" : [ { "rename": { "field": "xxx", "target_field": "yyy" } } ] } { "acknowledged": true } then reindex POST _reindex { "source": { "index": "source" }, "dest": { "index": "dest", "pipeline": "pipeline_rename_xxx" } }

Sumeru enterprise tiger privacy policy

Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. Data Privacy Policy At Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. we are committed to providing you with digitalization software products and services to meet your needs. Our commitment includes protecting personally identifiable information we obtain about you when you register to use one of our websites or become our customer (“Personal Information”). We want to earn your trust by providing strict safeguards to protect your Personal Information. This Policy applies to members, customers, former customers, users, and applicants. In the course of our business activities, Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. collects, processes, and shares Personal Information. Indian law gives individuals the right to limit some but not all sharing. This Policy explains what Personal Information we collect, process, and share. We describe how we do so, and why. The Policy also describes your rights to access a...