On 17/01/2015 18:19, Marvin Humphrey wrote:
On Sat, Jan 17, 2015 at 8:58 AM, Nick Wellnhofer <[email protected]> wrote:
Oops, I just saw that queries for "Foo" don't work either, so scratch that.
Can you show us your indexing and querying code or even a self-contained
test case?
The issue is probably that TermQuery's constructor takes exactly what you give
it, which may not match what's in the index. In this case, `foo` is in the
index, so queries for `Foo` don't work.
Ah yes, of course. Sorry for the noise.
Another approach to manually analyze fields for a TermQuery would be:
my $type = $schema->fetch_type('option_ndx');
# get_analyzer only works for FullTextType.
my $analyzer = $type->get_analyzer;
my $tokens = $analyzer->split('Foo');
# Make sure to check the size of the returned array.
my $term_query = Lucy::Search::TermQuery->new(
field => 'option_ndx',
term => $tokens->[0],
);
Some of this is explained in the QueryObjects tutorial and the
CustomQueryParser cookbook entry:
https://metacpan.org/pod/distribution/Lucy/lib/Lucy/Docs/Tutorial/QueryObjects.pod
https://metacpan.org/pod/distribution/Lucy/lib/Lucy/Docs/Cookbook/CustomQueryParser.pod
But unfortunately, the get_analyzer method of FullTextType is undocumented. I
think this should be fixed.
Nick