2010/3/11 Will Preston <Will(a)olsonkundigarchitects.com>om>:
Hello. I have an intranet set up that is using
mediawiki behind the scenes
for content. I set up a search box on the intranet pages, that calls the
api query module twice, first for title, then for text. I then take all the
text matches and call the index.php render module to get the page text, so I
can parse it for the searched term and highlight it in the results. I then
sort all the title and page text matches alphabetically by the page titles.
This all kind of works as intended, but seems like a crazy amount of
hackery, so I’m hoping there’s a better way.
list=search has an srprop=snippet
parameter and other goodies in srprop.
1) The highlighted search results include html and
wikitext code because
it’s produced by index.php’s render. Using strip_tags() helps a little, but
only when the matched string has both brackets ( < > ).
... which solves that.
2) Categories show up as page title matches if I
search on the regular
wiki page, but not when I go through the api. I assume the wiki code is just
also doing a category search and displaying it in the page title section?
This is because srnamespace defaults to 0 (main namespace only).
I think I’m also going to split up my title and text
search results. I had
them combined as that’s what the users are used to in a previous system, but
I think that just destroys whatever ranking system the search is using.
I have no idea how the search code works internally, I only know about
the code that reformats its results into an API response.
Roan Kattouw (Catrope)