Created
November 19, 2013 19:34
-
-
Save jprante/7551124 to your computer and use it in GitHub Desktop.
An example of broader/narrower SKOS for Elasticsearch SKOS plugin
This file contains hidden or 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
curl -XDELETE 'localhost:9200/test' | |
curl -XPOST 'http://localhost:9200/test' -d '{ | |
"settings" : { | |
"index" : { | |
"analysis" : { | |
"filter": { | |
"skosfilter" : { | |
"type": "skos", | |
"path": "/var/tmp/indexpath/", | |
"skosFile": "ukat_examples.n3", | |
"expansionType": "LABEL", | |
"skosType": "PREF ALT BROADER NARROWER" | |
} | |
}, | |
"analyzer" : { | |
"skos" : { | |
"type" : "custom", | |
"tokenizer" : "keyword", | |
"filter" : "skosfilter" | |
} | |
} | |
} | |
} | |
}, | |
"mappings" : { | |
"_default_" : { | |
"properties" : { | |
"subject" : { | |
"type" : "string", | |
"store" : true, | |
"index_analyzer" : "skos", | |
"search_analyzer" : "standard" | |
} | |
} | |
} | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/test/subjects/1' -d '{ | |
"title" : "Spearhead", | |
"description": "Roman iron spearhead. The spearhead was attached to one end of a wooden shaft.The spear was mainly a thrusting weapon, but could also be thrown. It was the principal weapon of the auxiliary soldier. (second - fourth century, Arbeia Roman Fort)", | |
"subject" : "Weapons" | |
}' | |
curl -XPUT 'http://localhost:9200/test/subjects/2' -d '{ | |
"title" : "Vitruvius Ballista", | |
"description": "This ballista is a palintone or stone throwing machine. Bestia represents the smallest stone thrower in the Roman army. It is a 2 libra (2 pounder). The stones would not be capable of knocking down walls, but would be ideal if used against groups of warriors or being dropped into hill forts or towns.", | |
"subject" : "Arms" | |
}' | |
curl -XPOST 'http://localhost:9200/test/_refresh' | |
# should give two hits | |
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{ | |
"query": { | |
"match" : { | |
"subject": "Arms" | |
} | |
} | |
}' | |
# should give two hits | |
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{ | |
"query": { | |
"match" : { | |
"subject": "Weapons" | |
} | |
} | |
}' | |
# should give no hit | |
curl -XGET 'http://localhost:9200/test/_search?pretty' -d '{ | |
"query": { | |
"match" : { | |
"subject": "foo bar" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment