Page MenuHomePhabricator

List number of search results in titles
Open, LowestPublic

Description

https://www.mediawiki.org/w/api.php?action=help&modules=query%2Bsearch

There's are example in the bottom of the page: api.php?action=query&list=search&srwhat=text&srsearch=meaning -- It lists "totalhits" for all entries and and "wordcount" for each entry.

Is there a URI to list the hits for "meaning" for each entry like "wordcount"?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 24 2018, 7:54 AM
David_Hedlund updated the task description. (Show Details)

Hi @David_Hedlund, thanks for taking the time to report this! Unfortunately this report lacks some information.

If you have a question how to use the API, please ask on https://lists.wikimedia.org/mailman/listinfo/mediawiki-api or in a support forum. (Phabricator is for bug reports and feature requests, basically.)

If this is a feature request (asking for functionality that does not exist yet): Please add a more complete description to this report: A clear list of specific steps to reproduce the situation, describing actual results, and describing expected results after performing the steps to reproduce.
You can edit the task description by clicking Edit Task. Thanks!

David_Hedlund added a comment.EditedJun 24 2018, 11:20 AM

Title:Text in page

  • Foo: Hello world.
  • Bar: Apples are good
  • Baz: Something in this world that takes you to another world.

URI that lists the word "world":

  • Foo: 1
  • Bar: 0
  • Baz: 2

@Aklapper I tried to describe it better. Do you understand it?

Title:Text in page

  • Foo: Hello world.
  • Bar: Apples are good
  • Baz: Another world, where we all are one.

URI that lists the word "world":

  • Foo: 1
  • Bar: 0
  • Baz: 2

Why is Baz: 2 if "Another world, where we all are one." only includes the word "world" once?
Bar would not be a listed search result anyway, if I understand correctly, as it has 0 matching?

What is the use case? In which situations is it relevant /helpful to know the wordcount in a title?

Again, if your question is "Does XYZ exist?" then that is a support question and out of scope for Phabricator. That seems to be the case here.
If you think that XYZ does not exist then you need to explain why it should exist and rephrase this task to become a feature request. https://mediawiki.org/wiki/How_to_report_a_bug explains how to structure your tasks: Provide steps to reproduce, expected outcome, and actual outcome, in separate sections.

@Aklapper I corrected the example. I think it's an issue if this cannot be listed because it should be possible to count hits in MediaWiki pages. For example curl+jq could be used as a search engine to list them in a terminal.

David_Hedlund added a comment.EditedJun 25 2018, 5:51 AM

This works:
search="meaning"; curl "https://www.mediawiki.org/w/api.php?action=query&list=search&srwhat=text&format=json&srsearch=$search" | jq .query.search[].title
search="meaning"; curl "https://www.mediawiki.org/w/api.php?action=query&list=search&srwhat=text&format=json&srsearch=$search" | jq .query.search[].wordcount

Proposed "jq .query.search[].hits" like this:
search="meaning"; curl "https://www.mediawiki.org/w/api.php?action=query&list=search&srwhat=text&format=json&srsearch=$search" | jq .query.search[].hits

I also suggest that results should be displayed next to the titles in MediaWiki's search page. I modified a screenshot to give examples, see "Free software (190 results)", "Free and open-sourde software (116 results)", etc, and the example under "Results from sister projects".

Vvjjkkii renamed this task from List number of search results in titles to heaaaaaaaa.Jul 1 2018, 1:02 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
JJMC89 renamed this task from heaaaaaaaa to List number of search results in titles.Jul 1 2018, 3:58 AM
JJMC89 raised the priority of this task from High to Needs Triage.
JJMC89 updated the task description. (Show Details)
This comment was removed by David_Hedlund.
Anomie moved this task from Unsorted to Blocked on the MediaWiki-API board.Jul 2 2018, 1:55 PM
Anomie added a subscriber: Anomie.

Implementing this would require that the SearchResult be able to expose this information and the search engine populate it.

Restricted Application added projects: Discovery, Discovery-Search. · View Herald TranscriptJul 2 2018, 1:56 PM
EBjune triaged this task as Lowest priority.Jul 5 2018, 5:14 PM
EBjune added a subscriber: EBjune.

We're not sure how this kind of feature would be useful, as frequency already bubbles the most relevant results to the top. Google doesn't even provide this information in results. It's not something we feel we should put the effort into unless there is a huge call for it and we better understand how this feature would be useful.