0

I have a simple service that wraps DokuWiki calls (https://www.dokuwiki.org/devel:xmlrpc#accessing_the_xml-rpc_interface) made via the PHP XML-RPC library. I am attempting to perform a DokuWiki search but cannot seem to get it it to work. Here is the relevant functionality in my service:

public function search($query)
{
    echo $query . "\n";

    // initialize the new message for the search method call
    $message = new xmlrpcmsg('dokuwiki.search');
    $message->addParam(new xmlrpcval($query, "string"));

    // return message results based on XMLRPC server response
    return $this->getResults( $this->_client->send($message) );
}

private function getResults($response)
{
    if( !$response->faultCode() ) {
       return $response->value();
    }

    throw new Exception( $response->faultString() );
}

My client code is making search according to the query syntax (outlined here https://www.dokuwiki.org/search):

function searchWiki($dokuwiki, $search, $ns)
{
   $query = "[ $search @$ns ]";
   return $dokuwiki->search($query);
}

However, it never seems to yield any search results, not matter what the search query is. E.g.,

Query:
[ user @detailed-manuals ]

Result:
object(xmlrpcval)#5 (3) {
  ["me"]=>
  array(1) {
    ["array"]=>
    array(0) {
    }
  }
  ["mytype"]=>
  int(2)
  ["_php_class"]=>
  NULL
}

Even searching in the global namespace yields nothing, though it should as the term "user" shows up any number of times. If anyone could offer insight, that would be most helpful.

dtg
  • 1,803
  • 4
  • 30
  • 44
  • 1
    According to [this xmlrpc client](https://github.com/gturri/dokuJClient/blob/2562ca086ed72b487bb0baca70cd76063e0e417f/src/dw/xmlrpc/DokuJClient.java#L478) and [this test](https://github.com/gturri/dokuJClient/blob/2562ca086ed72b487bb0baca70cd76063e0e417f/src/dw/xmlrpc/itest/T_XmlRpcQueries.java#L399), you might want to try without square brackets, ie: "$query = "$search @$ns";". Does it yield better results? – gturri Nov 12 '13 at 06:30
  • Thanks, removing the brackets did yield results! – dtg Nov 14 '13 at 18:23
  • Although, the results seem to be on the same exact page every time in the given namespace with the exact result string, regardless of search query. Not sure if this is the correct way to go either... – dtg Nov 14 '13 at 22:54
  • The search query should return a score for each page. It seems to be the number of time the pattern has been found on the page. Are those scores consistent with your queries? – gturri Nov 17 '13 at 18:08

1 Answers1

0

The issue was that I needed to execute the indexer.php script to index all of the pages in the DokuWiki installation per the link below. After running the script, I am getting plenty of results.

https://www.dokuwiki.org/indexer

dtg
  • 1,803
  • 4
  • 30
  • 44