Skip to content

Instantly share code, notes, and snippets.

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
curl -XPUT localhost:9200/test
curl -XPUT http://localhost:9200/test/data/_mapping -d '{
"data" : {
"dynamic_templates" : [
{
"string_template" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
curl localhost:9200/your_index/_search -d '{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"missing" : {
"field" : "phone_numbers.id"
}
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"mappings" : {
"demo" : {
"properties" : {
"demostring" : {
"type" : "string",
"analyzer" : "whitespace"
}
}
curl -XPUT localhost:9200/test/type/1 -d '{
"city" : {
"name" : "xxx",
"address" : "yyy"
}
}'
curl localhost:9200/test/_search -d '{
"query" : {
"query_string" : {
curl -XPUT localhost:9200/test/type/1 -d '{
"field1" : 10,
"field2" : 20
}'
curl -XPUT localhost:9200/test/type/2 -d '{
"field1" : 11,
"field2" : 20
}'
curl localhost:9200/test/_search -d '{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"terms" : {
"_type" : ["value1", "value2"]
}
import com.google.common.collect.UnmodifiableIterator;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.unit.TimeValue;
curl -XPUT localhost:9200/test -d '{
"mappings" : {
"type1" : {
"doc" : {
"type" : "object",
"enabled" : false
}
}
}
}'