0

I'm writing a perl script to retrieve search results from a Xapian database.

I uses the Search::Xapian module and tried the basic Xapian Query Example. This basic program allow to make a query and get a array of results sorted by relevancy. My problem is that the get_data() method return the whole datas from the document (url, filname, abstract, author, ...) mixed together as a string.

I searched in the CPAN module for a method to get each data one by one but I didn't find it.

Is it possible to get the filename, url, author, ... one by one to put them in a specific variable ?

JeanJouX
  • 2,555
  • 1
  • 25
  • 37
  • show your code that produces this output – Dr.Avalanche Aug 22 '16 at 11:57
  • `get_data()` is deliberately opaque to Xapian. Whatever you put in there, you get out; different languages make it easier to use different formats. JSON, YAML, TOML and XML are all feasible. `omindex` and `scriptindex` however use a _sui generis_ format which you can read by splitting on line ending then splitting on '=' to make key/value pairs. – James Aylett Aug 23 '16 at 12:30

1 Answers1

0

You've not posted the code to produce this, or details of your setup. See the simplesearch.pl example, rather than print it out, assign what you want to a variable:

# Display the results.
printf "%i results found.\n", $mset->get_matches_estimated();
printf "Results 1-%i:\n", $mset->size();

foreach my $m ($mset->items()) {
    printf "%i: %i%% docid=%i [%s]\n", $m->get_rank() + 1, $m->get_percent(), $m->get_docid(), $m->get_document()->get_data();
}
Dr.Avalanche
  • 1,944
  • 2
  • 28
  • 37