1

I ve this query, which i want to find every instance of human with name Jose (already a first name like John, very common) in wikidata spanish, and then I get only 10 results. I believe is the way of the subquery, like if I made the filter of my 50 previous results, but I can't move the conditions without breaking the query.

my query:

SELECT * WHERE {
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "EntitySearch" .
      bd:serviceParam wikibase:endpoint "www.wikidata.org" .
      bd:serviceParam mwapi:search "josé" .
      bd:serviceParam mwapi:language "es" .
      ?item wikibase:apiOutputItem mwapi:item .
      ?num wikibase:apiOrdinal true .
  }

  ?item (wdt:P279|wdt:P31) ?type
   FILTER (?type = wd:Q5)
OPTIONAL { ?item wdt:P569 ?fecha_de_nacimiento. }
    FILTER(?fecha_de_nacimiento > "1900-12-31T00:00:00Z"^^xsd:dateTime)
} ORDER BY ASC(?num)

and my edit, is similar in result:

SELECT * WHERE {
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "EntitySearch" .
      bd:serviceParam wikibase:endpoint "www.wikidata.org" .
      bd:serviceParam mwapi:search "josé" .
      bd:serviceParam mwapi:language "es" .
      ?item wikibase:apiOutputItem mwapi:item .
      ?num wikibase:apiOrdinal true .
      ?item (wdt:P279|wdt:P31) ?type
   FILTER (?type = wd:Q5)
  }


OPTIONAL { ?item wdt:P569 ?fecha_de_nacimiento. }
    FILTER(?fecha_de_nacimiento > "1900-12-31T00:00:00Z"^^xsd:dateTime)
} ORDER BY ASC(?num)
  • 1
    What happens if you get rid of the FILTER? Do you get more results? – Barry Carter Mar 11 '18 at 4:51
  • @BarryCarter for sure, but not data that I want, because is people born before 1900. But so I think the first subquery search for people before, give me 50 and then I filter that results so I get weird results. I move the filter to the first one but still, weird results. – MacGyver Mar 11 '18 at 15:38
4

...like if I made the filter of my 50 previous results...

Wikibase:mwapi supports the limit parameter of the Entity Search service:

SELECT ?item ?label ?order WHERE {
  VALUES (?type ?name) {(wd:Q5 "Jose")}
  SERVICE wikibase:mwapi {
      bd:serviceParam wikibase:api "EntitySearch" ;
                      wikibase:endpoint "www.wikidata.org" ;
                      mwapi:language "es" ;
                      mwapi:search ?name ;
                      mwapi:limit "50" .
      ?item wikibase:apiOutputItem mwapi:item .
      ?order wikibase:apiOrdinal true .
      ?label wikibase:apiOutput mwapi:label .
  }
  ?item wdt:P31 ?type .
  ?item wdt:P569 ?date. 
  FILTER (?date > "1900-12-31T00:00:00Z"^^xsd:dateTime) 
} ORDER BY ASC(?order) LIMIT 10

Try it!

As you can see, results are still weird (but try e. g. "José Mourinho" instead of "José").

Possibly you should add some filtering using CONTAINS.

If you want to search people by their given names, probably you should use the wd:P735 property, however, there is no fast way to get most "popular" or "relevant" results.

  • Thanks for you good response! Actually I don't want the limit of 50, the weird think I can figure in this is that how can be only 10 josé if I can list at least 30 in memory of people in wikipedia with named jose? – MacGyver Mar 11 '18 at 14:54
  • thats is the thing i cant understand :( why is happening that and how to fix it – MacGyver Mar 11 '18 at 14:55
  • 2
    My two cents: Wikidata contains a lot of people whose given name is "josé", but this request does not require that. It asks for people whose one of the aliases is simply "José". – Ettore Rizza Mar 11 '18 at 15:42
  • 1
    @LeandroTupone, it seems that this is an issue of Entity Search service. AFAIK, Entity Search service uses Elasticsearch index. Probably you could create an issue somewhere in subsubtasks of phabricator.wikimedia.org/T78157. As for triplestores, they are for things, not for strings. – Stanislav Kralin Mar 11 '18 at 16:18
  • 1
    @LeandroTupone, you are welcome :-). Possibly related: phabricator.wikimedia.org/T125500 – Stanislav Kralin Mar 12 '18 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.