Hi,
I'd like to know how we can choose the distance between two words that we search
in a text. I know there is an "op_near" operator but I don't know how I can
specified that the number of words between the two specified words should not
exceed 10 or 20 or x words.
I'm really sorry for my terrible English, I hope I'm understandable!
[Xapian-discuss] How to choose the proximity between search words
| Tweet |
|
Search Discussions
-
James Aylett at Dec 7, 2011 at 4:07 pm ⇧
On 7 Dec 2011, at 14:14, Nat wrote:
I'd like to know how we can choose the distance between two words that we search
in a text. I know there is an "op_near" operator but I don't know how I can
specified that the number of words between the two specified words should not
exceed 10 or 20 or x words.
Hey, Nat. For OP_NEAR (and OP_PHRASE), the "parameter" to the Xapian::Query constructor gives a "window" which will do what you want. The getting started guide has a little on these <http://getting-started-with-xapian.readthedocs.org/en/latest/concepts/search/queries.html#near-and-phrase>, although probably not nearly enough. I don't think it has practical examples of using them, but in the meantime the API docs have some details:
<http://xapian.org/docs/apidoc/html/classXapian_1_1Query.html#7e7b6b8ad0c915c2364578dfaaf6100b7a78c8353d5d06d3a38c1899ae762b21>
Hope this helps!
J
--
James Aylett
talktorex.co.uk - xapian.org - devfort.com -
James Aylett at Dec 22, 2011 at 3:16 pm ⇧
On 22 Dec 2011, at 14:36, Nat wrote:
So thanks to James and OP_NEAR operator, I can search for terms within 10 words
of each other. What I'd like is to choose the number of words : 10, 20, 50... Is
that possible?
Nat ? this is what the Query parameter is used for with OP_NEAR. It's called the "window" that the near operator works over.
J
--
James Aylett
talktorex.co.uk - xapian.org - devfort.com -
Nat at Jan 3, 2012 at 8:46 am ⇧
Hi! And happy new year :)
With the end of the year, I haven't had much time to work on my search
application. I just tried to use Xapian::Query constructor to specify my window
size, but I can't find the right syntax, nothing worked :(
This is my PHP code:
$queryOP = XapianQuery::OP_NEAR;
$proximity = 30;
$queryparser->set_default_op(XapianQuery::OP_NEAR);
$query = $queryparser->parse_query($searchexp,XapianQueryParser::FLAG_DEFAULT);
where searchexp is, for example, "vierge marie".
I've got my query, but I don't know how I can use Xapian::Query constructor or
any function of this class to specify my $proximity.
I have to admit I'm a little lost!
Thanks in advance
Nat
-
Olly Betts at Jan 4, 2012 at 1:32 am ⇧
You can't currently set the window size used by QueryParser if you setOn Tue, Jan 03, 2012 at 08:46:12AM +0000, Nat wrote:
$queryOP = XapianQuery::OP_NEAR;
$proximity = 30;
$queryparser->set_default_op(XapianQuery::OP_NEAR);
$query = $queryparser->parse_query($searchexp,XapianQueryParser::FLAG_DEFAULT);
default_op to OP_NEAR.I've got my query, but I don't know how I can use Xapian::QueryIf you build the phrase Query object by hand, you would do it like so:
constructor or any function of this class to specify my $proximity.
$query = new XapianQuery(XapianQuery::OP_NEAR, array('hello', 'world'), 30);
Cheers,
Olly
Related Discussions
Discussion Navigation
| view | thread | post |
Discussion Overview
| group | xapian-discuss |
| categories | xapian |
| posted | Dec 7, '11 at 2:14p |
| active | Jan 4, '12 at 9:58a |
| posts | 9 |
| users | 3 |
| website | xapian.org |
| irc | #xapian |
