jwbf icon indicating copy to clipboard operation
jwbf copied to clipboard

Article history (revisions), search, etc.

Open ghost opened this issue 11 years ago • 6 comments

Hi again!

As you library seems to be the only available library for Java (there are one or two apart, but those are not being updated more) when we talk about MediaWiki API (i.e., not through database dump), I did keep testing you library.

Are you thinking to introduce a way to work with the revisions?

Search for Wikitext in various pages? Seems that now they introduced the CirrusSearch and its able to do search with regular expressions (see http://www.mediawiki.org/wiki/Thread:Help_talk:CirrusSearch/Regular_expressions), but I don't known ifs available through the rest API.

Those features would be interesting for example, in the area of anti-vandalism.

ghost avatar Jul 07 '14 16:07 ghost

Hi guiwp,

good point, but actually I have a few other plans instead of adding search entities, but if you want to help it seems not very difficult. (Else I have to schedule this task for later.)

See: https://www.mediawiki.org/wiki/API:Search http://www.mediawiki.org/w/api.php (search for "Perform a full text search.")

Maybe like this:

public class Search extends TitleQuery<SearchResult> {
...
Get searchRequest = new ApiRequestBuilder().action("query") //
        .formatJson() //
        .paramNewContinue(mediaWikiVersion) //
        .param("list", "search") //
        .param("srsearch", "wikipedia") //
        .param("srbackend", "CirrusSearch") // or LuceneSearch
// http://www.mediawiki.org/w/api.php?action=query&list=search
// &srsearch=wikipedia&srbackend=CirrusSearch&format=json&continue=-||
...

public class SearchResult {
  final int namespace;
  final String title;
  final String snippet;
  ...
}

At JsonMapperTest.java you can find an example how to map any json response.

eldur avatar Jul 08 '14 05:07 eldur

Good answer, I found very simple and effective to start testing adding stuff into the code. But anyway, I feel that I can wait (as you said Else I have to schedule this task for later).

Thank you again :)

ghost avatar Jul 08 '14 15:07 ghost

I'm interested in adding a search function as described here.

fhocutt avatar Aug 01 '14 22:08 fhocutt

@guiwp have you tried gerhardgossen implementation? Actual without a toggle for srbackend but maybe enough?

eldur avatar Dec 13 '14 20:12 eldur

@eldur What's the status on getting old revisions of an article? I suppose it should be implemented by adding a support for rvendid and rvstartid API request parameters into the GetRevision -- or perhaps by adding a similar class dedicated only to getting specific revisions (i.e. having a List<SimpleArticle> as its primary return type). The query itself seems to look like this: /api.php?action=query&prop=revisions&titles=TitleOfTheArticle&rvprop=timestamp|user|comment|content&rvendid=OLDER_REVISION&rvstartid=NEWER_REVISION (switching the older and newer revisions if rvdir=newer is given as well).

ZeroOne3010 avatar Jul 13 '19 20:07 ZeroOne3010

@ZeroOne3010 if something is missing here send a pull request

eldur avatar Jul 24 '19 20:07 eldur