Created
April 21, 2015 11:42
-
-
Save redserpent7/a4866ce15924ab98ec1f to your computer and use it in GitHub Desktop.
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
#Create an Index | |
curl -XPUT 'localhost:9200/files | |
#Create index mapping enabling _source and disabling _all fields | |
#Without the store property set to true, no results are returned | |
curl -XPUT /files/rawfiles/_mapping -d '{ | |
"rawfiles": { | |
"_source": { | |
"enabled": true | |
}, | |
"_all": { | |
"enabled": false | |
}, | |
"_timestamp": { | |
"enabled": true, | |
"path": "timestamp" | |
}, | |
"properties": { | |
"fileid": { | |
"store": true, | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"userid": { | |
"store": true, | |
"index": "not_analyzed", | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"filesize": { | |
"store": true, | |
"index": "not_analyzed", | |
"type": "long" | |
}, | |
"filename": { | |
"store": true, | |
"omit_norms": true, | |
"index_analyzer": "def_analyzer", | |
"search_analyzer": "def_analyzer_search", | |
"type": "string" | |
}, | |
"extension": { | |
"analyzer": "keyword", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"modificationdate": { | |
"store": true, | |
"index": "not_analyzed", | |
"type": "date" | |
}, | |
"timestamp": { | |
"store": true, | |
"index": "not_analyzed", | |
"type": "date" | |
}, | |
"category": { | |
"store": true, | |
"index": "not_analyzed", | |
"type": "long" | |
}, | |
"content_ukw": { | |
"analyzer": "def_analyzer", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"content_br": { | |
"analyzer": "br_analyzer", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"content_da": { | |
"analyzer": "da_analyzer", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"content_de": { | |
"analyzer": "de_analyzer", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"content_en": { | |
"analyzer": "en_analyzer", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
}, | |
"content_es": { | |
"analyzer": "es_analyzer", | |
"store": true, | |
"omit_norms": true, | |
"type": "string" | |
} | |
} | |
} | |
}' | |
#After indexing some data, do a search query | |
curl -XPOST /files/rawfiles/_search -d '{ | |
"from": 0, | |
"size": 50, | |
"sort": [ | |
{ | |
"_score": { | |
"order": "desc" | |
} | |
} | |
], | |
"fields": [ | |
"filename", | |
"filesize" | |
], | |
"aggs": { | |
"extension": { | |
"terms": { | |
"field": "extension" | |
} | |
}, | |
"pagecount": { | |
"terms": { | |
"field": "pagecount" | |
} | |
}, | |
"dates": { | |
"date_range": { | |
"field": "modificationdate", | |
"format": "MM-yyyy", | |
"ranges": [ | |
{ | |
"from": "now-1M/M", | |
"to": "now", | |
"key": "one_month" | |
}, | |
{ | |
"from": "now-3M/M", | |
"to": "now-1M/M", | |
"key": "three_months" | |
}, | |
{ | |
"from": "0", | |
"to": "now-3M/M", | |
"key": "old" | |
} | |
] | |
} | |
} | |
}, | |
"query": { | |
"multi_match": { | |
"query": "retracted", | |
"fields": [ | |
"filename^3", | |
"content_*^2", | |
"content_ukw" | |
] | |
} | |
} | |
}' | |
#No hits will be returned without setting the store property to true for filename and content fileds | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment