is there any way to obtain, after a phrasal query, the position of the terms found? i'll try to be more clear with an example. if i search for "milk coffe brain" phrase, and i have a result in document 5, is there any way to get the position (that xapian knows...) of this term ( e.g. milk in pos 147, coffe 148 and brain 149)? -- ...lorenzo
Jens Dobberthin
2007-Jul-11 15:17 UTC
[Xapian-discuss] get position terms from a query result
Some Python code as a hint: db = [your xapain database] enquire.set_query(query) matches = enquire.get_mset(0, 1000) for match in matches: terms = enquire.matching_terms(match[MSET_DID]) for t in terms: positions = db.positionlist(match[MSET_DID], t) for p in positions: print p Greetings, Jens.
Richard Boulton
2007-Jul-11 15:41 UTC
[Xapian-discuss] get position terms from a query result
...lorenzo wrote:> is there any way to obtain, after a phrasal query, the position of the > terms > found? > i'll try to be more clear with an example. > if i search for "milk coffe brain" phrase, and i have a result in document > 5, is there any way to get the position (that xapian knows...) of this term > ( e.g. milk in pos 147, coffe 148 and brain 149)?I'm afraid there isn't currently any way to get this: at the moment, you'll need to open the document, get the position lists for the terms from it, and look for the phrase yourself. It would be nice to have API support for doing this, but it probably wouldn't be able to directly reuse the information determined during the initial match process, because this would require quite a bit of restructuring of the matcher, and would also increase the memory usage during the match. Also, note that if the query is of the form "a OR (b PHRASE c)" we may not have a matching phrase, so the API would need to be flexible enough to represent this. -- Richard