微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么 SPARQL 查询在我们的 Wikidata Docker WDQS 中没有按预期工作

如何解决为什么 SPARQL 查询在我们的 Wikidata Docker WDQS 中没有按预期工作

SPARQL 查询在我们的 Wikidata Docker WDQS(维基数据查询服务)中没有按预期工作。

我们正在 AWS EC2 上运行 wikibase docker。首先,我将描述 3 个不起作用的查询,然后提供有关我们设置的详细信息。我们怀疑 docker-compose.yml 文件文章末尾)中的设置不正确。

查询 1 - 未选择任何结果。查询是:

# return item's whose favorite city (P8) is Chicago (Q7)
SELECT ?item ?itemLabel WHERE {
    ?item wdt:P8 wd:Q7 . 
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

即使我们输入了项目 Q1,其最喜欢的城市 (P8) 是芝加哥 (Q7),查询也会返回“No Matching Records Found”。请注意,WDQS/sparql UI 中的“鼠标悬停”确实表示 P8 是最喜欢的城市,Q7 是芝加哥,但“鼠标悬停”数据来自 elasticsearch,而不是 WDQS 服务。

查询 2 - 一个更简单的查询,返回结果,但返回的 itemLabel 是 Q 号而不是文本。返回的链接似乎是正确的,并且确实链接到了正确的项目。然而,如果我使用了一个不在我们维基库中的 Q 号码(比如 Q9999999999),它仍然会返回一个链接(当然这个链接将无法工作,因为 Q 号码不存在)。

查询是:

SELECT ?item ?itemLabel
WHERE {VALUES ?item {wd:Q1}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }}

Query 2 and result

查询 3 - 一个简单的查询,除了指向我们 wikibase 的链接具有值 wikibase.svc 而不是指向我们 wikibase 的有效链接之外,它看起来可以正常工作。这是查询

SELECT * WHERE { ?a ?b ?c}

Query 3 and results

在结果中,我认为“wikibase.svc”应该是我们 wikibase 服务器的 url。

我们的设置:我们在 AWS ALB(应用程序负载均衡器 - 也管理 SSL)后面的 AWS EC2 (Centos 8) 上运行 wikibase docker

我们使用 xxxx.xxxx.xxxx.xxxx.edu/sparql/ 在端口 8282 上访问 EC2,因此访问 wdqs-frontend 容器。 (到端口的路由,由 ALB 管理)

xxxx.xxxx.xxxx.xxxx.edu 由 ALB 路由到 EC2 上的端口 8181,因此是 wikibase 容器。

对于 wdqs-frontend 容器,我们已更新 /etc/Nginx/Nginx.conf 以包含 /etc/Nginx/conf.d/sparqlpath.conf 而不是 default.conf。

Sparqlpath.conf 在下面。

# This file,sparqlpath.conf,replaces the file (default.conf) provided by the wikibase/wdqs-frontend docker image.
# Modifications:
# Joe Troy 01/15/2021 add location /sparql and sparlq_upstream because users will use [servername]/sparql to connect to the sparql frontend
#                     also note that this change required changes to the AWS application Load Balancer (ALB)

upstream sparql_upstream {
    server 127.0.0.1:80;
}

server {
    listen       80;
    server_name  localhost;

    location /sparql {
        # the trailing slash is key as not to look for a slash sub directory
        #include       /etc/Nginx/mime.types;
        proxy_pass http://sparql_upstream/;
    }
    location /proxy/wikibase {
        rewrite /proxy/wikibase/(.*) /$1 break;
        proxy_pass http://wikibase.svc:80;
    }
    location /proxy/wdqs {
        rewrite /proxy/wdqs/(.*) /$1 break;
        proxy_pass http://wdqs-proxy.svc:80;
    }
    location / {
        root   /usr/share/Nginx/html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/Nginx/html;
    }

}

最后是我们的 docker-compose.yml 文件

# Wikibase with Query Service
#
# This docker-compose example can be used to pull the images from docker hub.
#
# Examples:
#
# Access Wikibase via "http://localhost:8181"
#   (or "http://$(docker-machine ip):8181" if using docker-machine)
#
# Access Query Service via "http://localhost:8282"
#   (or "http://$(docker-machine ip):8282" if using docker-machine)
version: '3'

services:
  wikibase:
    #image: wikibase/wikibase:1.34-bundle
    #
    #NOTES regarding the authorities.library.illinois.edu implementation
    #The wikibase image is modified so it has settings relevent to authorities.library.illinois.edu
    #if a new version of the wikibase docker image is used
    #changes to the /LocalSettings.PHP.template should be examined
    #any changes might need to be reflected in ./wikibase/LocalSettings.PHP.template in this repository
    #
    #Modified to use a Dockerfile
    build:
      context: .
      dockerfile: ./wikibase/Dockerfile
    links:
      - MysqL
    ports:
    # CONfig - Change the 8181 here to expose Wikibase & Mediawiki on a different port
     - "8181:80"
    volumes:
      - mediawiki-images-data:/var/www/html/images
      - quickstatements-data:/quickstatements/data
      - /etc/localtime:/etc/localtime:ro
    depends_on:
    - MysqL
    - elasticsearch
    restart: unless-stopped
    networks:
      default:
        aliases:
         - wikibase.svc
         - xxxx.xxxx.xxxx.xxxx.edu
         # CONfig - Add (added directly above) your real wikibase hostname here,for example wikibase-registry.wmflabs.org
    environment:
      - DB_SERVER=MysqL.svc:3306
      - MW_ELASTIC_HOST=elasticsearch.svc
      - MW_ELASTIC_PORT=9200
      # CONfig - Change the default values below
      - MW_ADMIN_NAME=WikibaseAdmin
      - MW_ADMIN_PASS=${ENV_VAR_WikibaseDockerAdminPass}
      - MW_ADMIN_EMAIL=admin@example.com
      - MW_WG_SECRET_KEY=secretkey
      # CONfig - Change the default values below (should match MysqL values in this file)
      - DB_USER=wikiuser
      - DB_PASS=${ENV_VAR_sqlpass}
      - DB_NAME=my_wiki
      - QS_PUBLIC_SCHEME_HOST_AND_PORT=http://localhost:9191
      - SMTP_PASS=${ENV_VAR_sparkpostpass}
  MysqL:
    image: mariadb:10.3
    restart: unless-stopped
    volumes:
      - mediawiki-MysqL-data:/var/lib/MysqL
      - /etc/localtime:/etc/localtime:ro
    environment:
      MysqL_RANDOM_ROOT_PASSWORD: 'yes'
      # CONfig - Change the default values below (should match values passed to wikibase)
      MysqL_DATABASE: 'my_wiki'
      MysqL_USER: 'wikiuser'
      MysqL_PASSWORD: '${ENV_VAR_sqlpass}'
    networks:
      default:
        aliases:
         - MysqL.svc
  wdqs-frontend:
    #image: wikibase/wdqs-frontend:latest
    build:
      context: .
      dockerfile: ./wdqs-frontend/Dockerfile
    restart: unless-stopped
    ports:
    # CONfig - Change the 8282 here to expose the Query Service UI on a different port
     - "8282:80"
    depends_on:
    - wdqs-proxy
    networks:
      default:
        aliases:
         - wdqs-frontend.svc
    environment:
      - WIKIBASE_HOST=xxxx.xxxx.xxxx.xxxx.edu
      - WDQS_HOST=wdqs-proxy.svc
    volumes:
      - /etc/localtime:/etc/localtime:ro
  wdqs:
    image: wikibase/wdqs:0.3.10
    restart: unless-stopped
    volumes:
      - query-service-data:/wdqs/data
      - /etc/localtime:/etc/localtime:ro
    tmpfs: /tmp
    command: /runBlazegraph.sh
    networks:
      default:
        aliases:
         - wdqs.svc
    environment:
      - WIKIBASE_HOST=xxxx.xxxx.xxxx.xxxx.edu
      - WIKIBASE_SCHEME=https
      - WDQS_HOST=wdqs.svc
      - WDQS_PORT=9999
    expose:
      - 9999
  wdqs-proxy:
    image: wikibase/wdqs-proxy
    restart: unless-stopped
    environment:
      - PROXY_PASS_HOST=wdqs.svc:9999
    ports:
     - "8989:80"
    depends_on:
    - wdqs
    volumes:
      - /etc/localtime:/etc/localtime:ro
    networks:
      default:
        aliases:
         - wdqs-proxy.svc
  wdqs-updater:
    image: wikibase/wdqs:0.3.10
    restart: unless-stopped
    command: /runUpdate.sh
    depends_on:
    - wdqs
    - wikibase
    networks:
      default:
        aliases:
         - wdqs-updater.svc
    environment:
     - WIKIBASE_HOST=wikibase.svc
     - WIKIBASE_SCHEME=http
     - WDQS_HOST=wdqs.svc
     - WDQS_PORT=9999
    volumes:
      - /etc/localtime:/etc/localtime:ro
  elasticsearch:
    image: wikibase/elasticsearch:6.5.4-extra
    restart: unless-stopped
    networks:
      default:
        aliases:
         - elasticsearch.svc
    environment:
      discovery.type: single-node
      ES_JAVA_OPTS: "-xms512m -Xmx512m"
    volumes:
      - /etc/localtime:/etc/localtime:ro
  # CONFING,in order to not load quickstatements then remove this entire section
  quickstatements:
    image: wikibase/quickstatements:latest
    ports:
     - "9191:80"
    depends_on:
     - wikibase
    volumes:
     - quickstatements-data:/quickstatements/data
     - /etc/localtime:/etc/localtime:ro
    networks:
      default:
        aliases:
         - quickstatements.svc
    environment:
      - QS_PUBLIC_SCHEME_HOST_AND_PORT=http://localhost:9191
      - WB_PUBLIC_SCHEME_HOST_AND_PORT=http://localhost:8181
      - WIKIBASE_SCHEME_AND_HOST=http://wikibase.svc
      - WB_PROPERTY_NAMESPACE=122
      - "WB_PROPERTY_PREFIX=Property:"
      - WB_ITEM_NAMESPACE=120
      - "WB_ITEM_PREFIX=Item:"

volumes:
  mediawiki-MysqL-data:
  mediawiki-images-data:
  query-service-data:
  quickstatements-data:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?