Skip to content

Instantly share code, notes, and snippets.

View sameek's full-sized avatar

sameek sameek

  • Arosys
  • India
View GitHub Profile
@sameek
sameek / Consumer.java
Created November 7, 2011 05:49
Consumer
while(true){
if(connection.isOpen()){
logger.debug("MQ Connection is Opened");
}else{
logger.debug("MQ Connection is Closed");
}
messageFromQueue = rabbitmqUtil.getMessageFromQueue(waitTime, connection, exchangeName, routekeyName);
logger.debug("messageFromQueue Obtained: "+messageFromQueue);
if(messageFromQueue == null){
boolStatus = false;
@sameek
sameek / bulk api format
Created January 9, 2012 05:20
This bulk command is used to create index with custom analyzer.
{"index" : { "_index" : "test", "_type" : "type1", "_id" : "3", "_analyzer":"myanalyzer" } }
{"type1" : { "name" : "my name is john" } }
{"myanalyzer" : {"type" : "custom", "tokenizer" :"mytokenizer","filter" :"myfilter"}}
{"mytokenizer": {"type":"whitespace"}}
{"myfilter":{"type":"stop" "stopwords" : [is]}}
{"create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{"type1" : { "name" : "my name is john" } }
@sameek
sameek / Exception
Created January 9, 2012 05:26
This Exception will raise when i try to override the default analyzer with custom analyzer.
org.elasticsearch.common.jackson.JsonParseException: Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries
at [Source: [B@1710808; line: 1, column: 296]
at org.elasticsearch.common.jackson.JsonParser._constructError(JsonParser.java:1291)
at org.elasticsearch.common.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385)
at org.elasticsearch.common.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306)
at org.elasticsearch.common.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:312)
at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:46)
at org.elasticsearch.action.bulk.BulkRequest.add(BulkRequest.java:121)
at org.elasticsearch.client.action.bulk.BulkRequestBuilder.add(BulkRequestBuilder.java:84)
at org.elasticsearch.river.rabbitmq.RabbitmqRiver$Consumer.run(RabbitmqRiver.java:216)
@sameek
sameek / stopwords_eng.txt
Created January 16, 2012 06:07
Custom analyzer Mapping
{"index" : { "_index" : "test1", "_type" : "type1", "_id" : "1", "_analyzer":"myanalyzer" } }
{ "type1" : { "name" : "my name is john" } }
{ "myanalyzer" : {"type" : "custom", "tokenizer" :"whitespace","filter" :["myfilter1"]}}
{"myfilter1":{"type":"stop" "stopwords_path":"D:\resources\stopwords_eng.txt" ,"ignore_case":true}}
{"create" : { "_index" : "test1", "_type" : "type1", "_id" : "1" } }
{ "type1" : { "name" : "my name is john" } }
@sameek
sameek / gist:1619806
Created January 16, 2012 08:56
java Generated Mapping
{"index":{"analysis":{"analyzer":{"default":{"type":"custom","tokenizer":"whitespace","filter":["asciifolding","lowercase","stopwordfilter"],"filter":"{"stopwordfilter":{"type":"stop","stopwords_path":"D:\\RabbitmqRiverExample\\RabbitmqRiverExample\\resources\\stopwords_eng.txt","ignore_case":"true"}}"}}}}}
@sameek
sameek / gist:1620578
Created January 16, 2012 12:09
java code for define custom mapping
try {
XContentBuilder stopwordfilter = null;
XContentBuilder indexSettings = null;
stopwordfilter=XContentFactory.jsonBuilder();
stopwordfilter.startObject()
.startObject("stopwordfilter")
.field("type","stop")
.field("stopwords_path","F:\\resources\\stopwords_eng.txt")
.field("ignore_case","true")
@sameek
sameek / gist:1626452
Created January 17, 2012 12:12
River Mapping
{ "index" : { "_index" :"idx_testtable", "_type" :"test_type", "_id" :"7"},{"analysis": {"analyzer":{"myindexanalyzer": {"type" :"custom","tokenizer": "whitespace","filter": ["lowercase", "customstopfilter", "asciifolding"]},"mysearchanalyzer": {"type" :"custom","tokenizer": "whitespace" }},{"filter":{"customstopfilter":{"type":"stop" ,"stopwords_path" :"F:\ElasticIndexManagementService\resources\stopwords_eng.txt" ,"ignore_case":true}}}}}}
{ "test_type" :{"index_analyzer" : "myindexanalyzer","search_analyzer" : "mysearchanalyzer"}}
{ "test_type" :{"id":7,"Description":" Technologies Inc"}}
{ "create" : { "_index" :"idx_testtable", "_type" :"test_type", "_id" :"7" }}
{ "test_type" :{"id":7,"Description":" Technologies Inc"}}
@sameek
sameek / Analyzer Setting source
Created January 19, 2012 05:57
RabbitMQ River With Custom Analyzer
{
"index" : {
"analysis" : {
"analyzer" : {
"customindexanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","mystopword"],
"char_filter" :["html_strip"]
},
{
"index" : {
"analysis" : {
"analyzer" : {
"manualindexanalyzer" : {
"type":"custom",
"tokenizer" : "whitespace",
"filter" : ["lowercase","asciifolding","length","myelision"],
"char_filter" :["html_strip"]
},
@sameek
sameek / gist:1868365
Created February 20, 2012 08:07
correct approach to get fields value from an index
float boost = (float) 1.0;
int minimumNumberShouldMatch = 2;
BoolQueryBuilder boolquery = new BoolQueryBuilder();
QueryStringQueryBuilder customerqueryStringQueryBuilder = new QueryStringQueryBuilder(customerid).analyzer("mainsearchanalyzer");
QueryStringQueryBuilder accountqueryStringQueryBuilder = new QueryStringQueryBuilder(secondaryMachingData).analyzer("mainsearchanalyzer");
BoolQueryBuilder boolquery1 = boolquery.boost(boost).minimumNumberShouldMatch(minimumNumberShouldMatch).should(customerqueryStringQueryBuilder).should(accountqueryStringQueryBuilder);
SearchResponse searchResponse = client.prepareSearch(masterIndexName).setSearchType(SearchType.DEFAULT).setTypes(customerExceptionIndexName).setQuery(boolquery1).execute().actionGet();
logger.debug("searchResponse Object:: \n" + searchResponse);