The only query type which allows you to anchor a term to the beginning
of the field is span_first.
Example usage:
Unfortunately, span-type queries only accept other span queries, so you
can't use the wildcard or prefix queries. In order to achieve what you
want, you'd need to find all the terms beginning with 'mo' in a separate
facets query, and create a span_term query for each term, all wrapped up
in a span_or query.
Not ideal I know...
the alternative would be to maintain another version of the field which
is not analyzed (or uses eg just the lower case token filter)
thanks for your suggestions, I was thinking of going with maintaining
an extra non-analysed field, since I have once already for sorting,
but trying this out in lucene, this type of field seems only to match
on the whole string:
e.g.
seach = Money* returns nothing
but
search = Money Market Dealer* would return "Money Market Dealer"
I could be wrong because this was a quick test I did on an in-memory
index I was creating in Lucene.
Unfortunately, span-type queries only accept other span queries, so you
can't use the wildcard or prefix queries. In order to achieve what you
want, you'd need to find all the terms beginning with 'mo' in a separate
facets query, and create a span_term query for each term, all wrapped up
in a span_or query.
Not ideal I know...
the alternative would be to maintain another version of the field which
is not analyzed (or uses eg just the lower case token filter)
thanks for your suggestions, I was thinking of going with maintaining
an extra non-analysed field, since I have once already for sorting,
but trying this out in lucene, this type of field seems only to match
on the whole string:
e.g.
seach = Money* returns nothing
but
search = Money Market Dealer* would return "Money Market Dealer"
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.