Created
December 11, 2013 23:05
-
-
Save rahul-m/7920182 to your computer and use it in GitHub Desktop.
Gist that creates a repository to store log messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove old data | |
curl -XDELETE "http://localhost:9200/mrisk/" | |
# Create index with settings | |
curl -XPOST "http://localhost:9200/mrisk/" -d ' | |
{ | |
"settings":{ | |
"index":{ | |
"analysis":{ | |
"analyzer":{ | |
"mrisk":{ | |
"type":"custom", | |
"tokenizer":"standard", | |
"filter":[ | |
"lowercase", | |
"asciifolding" | |
] | |
} | |
}, | |
"filter":{ | |
"elision":{ | |
"type":"elision", | |
"articles":[ | |
"l", | |
"m", | |
"t", | |
"qu", | |
"n", | |
"s", | |
"j", | |
"d" | |
] | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
# Define mapping | |
curl -XPOST "http://localhost:9200/mrisk/logrec/_mapping" -d ' | |
{ | |
"user":{ | |
"_all":{ | |
"analyzer":"mrisk" | |
}, | |
"properties":{ | |
"test":{ | |
"type":"string" | |
}, | |
"message":{ | |
"type":"string", | |
"index":"analyzed", | |
"analyzer":"mrisk" | |
}, | |
"date_creation":{ | |
"type":"date", | |
"format":"yyyy-MM-dd HH:mm:ss" | |
} | |
} | |
} | |
} | |
' | |
# Create Document | |
curl -XPOST "http://localhost:9200/mrisk/logrec/" -d ' | |
{ | |
"test":"FlexCube", | |
"date_creation":"2013-12-21 05:46:59", | |
"message":"<Trade TradeId=\"FlexCubeCash_001#0103347CAD2203178.000000000\" TradeReader=\"MarsCashTradeReader\" Model=\"\"/>" | |
} | |
' | |
# Create Document | |
curl -XPOST "http://localhost:9200/mrisk/logrec/" -d ' | |
{ | |
"test":"FlexCube", | |
"date_creation":"2013-12-21 05:46:59", | |
"message":"<Trade TradeId=\"FlexCubeCash_001#123456CAD2203178.000000000\" TradeReader=\"MarsCashTradeReader\" Model=\"\"/>" | |
} | |
' | |
# Create Document | |
curl -XPOST "http://localhost:9200/mrisk/logrec/" -d ' | |
{ | |
"test":"FlexCube", | |
"date_creation":"2013-12-21 05:46:59", | |
"message":"<Trade TradeId=\"FlexCubeCash_001#7893347CAD2203178.000000000\" TradeReader=\"MarsCashTradeReader\" Model=\"\"/>" | |
} | |
' | |
# Wait for ES to be synced (aka refresh indices) | |
curl -XPOST "http://localhost:9200/mrisk/_refresh" | |
# Search | |
curl -XPOST "http://localhost:9200/mrisk/logrec/_search?pretty=true" -d ' | |
{ | |
"query":{ | |
"bool":{ | |
"must":[], | |
"must_not":[], | |
"should":[ | |
{ | |
"query_string":{ | |
"default_field":"logrec.message", | |
"query":"FlexCubeCash_001#7893347CAD2203178.000000000" | |
} | |
} | |
] | |
} | |
}, | |
"from":0, | |
"size":10, | |
"sort":[], | |
"facets":{} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment