Skip to content

Instantly share code, notes, and snippets.

View nachiketkb's full-sized avatar

Nachiket Bhagwat nachiketkb

  • Boulder, Colorado
View GitHub Profile
@nachiketkb
nachiketkb / QueryBuilders not working
Created July 23, 2011 13:32
Query Builders unable to build queries.
package nachiket.trial;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.CustomScoreQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building uploader 1.0
[INFO] ------------------------------------------------------------------------
Downloading: http://192.168.1.5/artifactory/ext-snapshot-local/org/elasticsearch/elasticsearch/0.16.2/elasticsearch-0.16.2.pom
Downloading: http://192.168.1.5/artifactory/ext-snapshot-local/org/elasticsearch/elasticsearch/0.16.2/elasticsearch-0.16.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
@nachiketkb
nachiketkb / CustomScoreQueryBuilder
Created July 21, 2011 05:11
CustomScoreQueryBuilder.class working strangely.
package mypackage;
import org.elasticsearch.index.query.xcontent.BoolQueryBuilder;
import org.elasticsearch.index.query.xcontent.CustomScoreQueryBuilder;
import org.elasticsearch.index.query.xcontent.QueryBuilders;
public class Tryout {
public static void main(String args[]) throws UnknownHostException, MongoException
@nachiketkb
nachiketkb / Error code.
Created July 8, 2011 10:57
Error code.
org.elasticsearch.search.SearchParseException: [twitter][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{
"query":
{
"custom_score":
{
"query":{"match_all":{}},
"lang" : "native" , "script" : "foo"
}
}
}]]
@nachiketkb
nachiketkb / Script with null checking.
Created July 8, 2011 07:09
Script not working correctly
curl -XPUT localhost:9200/test/doc/1 -d '
{
"user" : 2,
"name" :2
}'
{"ok":true,"_index":"test","_type":"doc","_id":"1","_version":1}
curl -XPUT localhost:9200/test/doc/2 -d '
{
"name": 1
}'
@nachiketkb
nachiketkb / Distance script.
Created July 7, 2011 04:47
Distance not working
curl -XPUT localhost:9200/twitter/script/1 -d '
{
"user" : "kimchy" ,
"location" : { "lat" : 20.32 , "lon" : 23.23 }
}'
{"ok":true,"_index":"twitter","_type":"script","_id":"1","_version":3}
curl -XGET 'localhost:9200/twitter/script/_search?pretty=true' -d '
{
"query":
@nachiketkb
nachiketkb / Geo Location
Created July 6, 2011 16:08
Error exist in geo location file.
curl -XPUT 'localhost:9200/twitter/script/1' -d '
{
"location":
{
"lat": 10,
"lon": 10
}
}'
{"ok":true,"_index":"twitter","_type":"script","_id":"1","_version":2}
@nachiketkb
nachiketkb / Error in Script
Created July 6, 2011 14:40
There is an error in the script.
curl -XPOST localhost:9200/twitter/script -d '{"user" : 1}'
{"ok":true,"_index":"twitter","_type":"script","_id":"QdNvKdECReqKmJXz5XhJFw","_version":1}
curl -XGET 'http://127.0.0.1:9200/twitter/script/_search?pretty=1' -d '
{
"query" : {
"custom_score" : {
"script" : "_doc[\u0027user\u0027]",
"query" : {
"match_all" : {}
@nachiketkb
nachiketkb / Error in Script
Created July 6, 2011 12:53
I am getting error in using a simple script. Can anybody take a look at what is wrong? I want to use doc['field_name'] but it is throwing error. I want to use doc['field_name'] in my code.
curl -XPOST localhost:9200/twitter/script -d '{"user" : 1}'
{"ok":true,"_index":"twitter","_type":"script","_id":"QdNvKdECReqKmJXz5XhJFw","_version":1}
curl -XGET 'localhost:9200/twitter/script/_search?pretty=true' -d '
{
"query":
{
"custom_score":
{
"query":{"match_all":{}},