View gist:9893141
/*
* 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
View gist:2991425
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;
View explicit data mapping
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" : {
View gist:2721336
curl localhost:9200/your_index/_search -d '{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"missing" : {
"field" : "phone_numbers.id"
}
View gist:2688072
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"mappings" : {
"demo" : {
"properties" : {
"demostring" : {
"type" : "string",
"analyzer" : "whitespace"
}
}
View gist:2652028
curl -XPUT localhost:9200/test/type/1 -d '{
"city" : {
"name" : "xxx",
"address" : "yyy"
}
}'
curl localhost:9200/test/_search -d '{
"query" : {
"query_string" : {
View gist:2643463
curl -XPUT localhost:9200/test/type/1 -d '{
"field1" : 10,
"field2" : 20
}'
curl -XPUT localhost:9200/test/type/2 -d '{
"field1" : 11,
"field2" : 20
}'
View gist:2621490
curl localhost:9200/test/_search -d '{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"terms" : {
"_type" : ["value1", "value2"]
}
View gist:2587993
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;
View gist:2580514
curl -XPUT localhost:9200/test -d '{
"mappings" : {
"type1" : {
"doc" : {
"type" : "object",
"enabled" : false
}
}
}
}'