Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P5976
(An Untitled Masterwork)
Active
Public
Actions
Authored by
EBernhardson
on Sep 8 2017, 7:47 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F9390239:
Sep 8 2017, 7:47 AM
2017-09-08 07:47:21 (UTC+0)
Subscribers
None
#!/bin/sh
curl -XDELETE localhost:9200/wikidata
|
jq .
curl -XPUT localhost:9200/wikidata -d
'{
"settings": {
"analysis": {
"analyzer": {
"keyword_before_colon": {
"tokenizer": "colon_tokenizer",
"filter": ["single_token_limit", "keep_properties"]
},
"keep_properties_prefix": {
"tokenizer": "keyword",
"filter": ["keep_properties_prefix_filter", "strip_p_filter"]
}
},
"tokenizer": {
"colon_tokenizer": {
"type": "pattern",
"pattern": ":"
}
},
"filter": {
"single_token_limit": {
"type": "limit",
"max_token_count": 1
},
"keep_properties": {
"type": "keep",
"keep_words": ["P31", "P42"]
},
"keep_properties_prefix_filter": {
"type": "pattern_capture",
"preserve_original": false,
"patterns": [
"^(P(?:31|42).*)$",
"^(P).*$"
]
},
"strip_p_filter": {
"type": "stop",
"stopwords": ["P"]
}
}
}
},
"mappings": {
"page": {
"properties": {
"relationships": {
"type": "text",
"analyzer": "keep_properties_prefix",
"search_analyzer": "keyword",
"fields": {
"properties": {
"type": "text",
"analyzer": "keyword_before_colon",
"search_analyzer": "keyword"
}
}
}
}
}
}
}'
|
jq .
curl -XPUT localhost:9200/wikidata/page/1 -d
'{"relationships": ["P31:Q54321", "P1:Q1234", "P31:Q7654", "P42:Q4444"]}'
|
jq .
curl -XGET localhost:9200/wikidata/page/1/_termvectors -d
'{"fields": ["relationships", "relationships.properties"]}'
|
jq
'.term_vectors | with_entries({key: .key, value: .value.terms | to_entries | map(.key)})'
Event Timeline
EBernhardson
created this paste.
Sep 8 2017, 7:47 AM
2017-09-08 07:47:21 (UTC+0)
EBernhardson
mentioned this in
T175199: Index certain statements for Wikidata items
.
Log In to Comment