Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F31623437
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Tgr
Feb 20 2020, 3:21 AM
2020-02-20 03:21:10 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
#!/bin/bash
set -e
# customize these if you don't use vagrant
FORWARDED_PORT=`cat /vagrant/.settings.yaml | ack '^http_port:\s*(\d+)$' --output '$1' || echo 8080`
ACTION_API=http://dev.wiki.local.wmftest.net:$FORWARDED_PORT/w/api.php
ELASTIC_API=http://localhost:9200
# $1: article title, $2: article text, outputs page ID
api_edit() {
curl -s -d "format=json&action=edit&title=$1&text=$2" --data-urlencode 'token=+\' "$ACTION_API"
}
# $1: page ID, $2: ORES data as JSON string
api_index() {
curl -s -XPOST "$ELASTIC_API/wiki_content/page/$1/_update" -H 'Content-Type: application/json' -d '{"doc": {"ores_articletopics": '"$2"' }}'
}
# $1: article title, $2: article text, $3: ORES data as JSON string
api_execute() {
output=$(api_edit $1 $2)
echo "$output" | jq .
page_id=$(echo "$output" | jq '.edit.pageid')
mwscript extensions/CirrusSearch/maintenance/forceSearchIndex.php --ids $page_id
api_index $page_id "$3" | jq .
}
# test data; page name, page content, ES articletopic field content
api_execute Test_art "art" '["art|980"]'
api_execute Test_science "science" '["science|970"]'
api_execute Test_both "art science" '["art|600","science|550"]'
api_execute Test_none "-" '[]'
# check by visiting Special:ApiSandbox#action=query&format=json&prop=cirrusdoc&titles=Test%20art%7CTest%20science%7CTest%20both%7CTest%20none
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8324091
Default Alt Text
raw.txt (1 KB)
Attached To
Mode
P10461 Help script for setting up ORES articletopics test data
Attached
Detach File
Event Timeline
Log In to Comment