I think you could probably use a BooleanQuery to do this. Something like
this, although I haven't tested it. Your LuceneQuery1 just results in a
call to StandardQueryParser.parse, so you can combine that with your
spatial query:
LuceneQuery<Long, Station> luceneQuery2 =
luceneService
.createLuceneQueryFactory()
.create("stationNameIndex", "stations-region", index -> {
BooleanQuery query = new BooleanQuery();
query.add(new StandardQueryParser().parse(queryString, name),
BooleanQuery.Occur.MUST);
query.add(SpatialHelper.findWithin(-122.8515139, 45.5099231,
0.5), , BooleanQuery.Occur.MUST);
return query;
}
On Tue, Jan 28, 2020 at 11:36 AM vas aj <[email protected]> wrote:
> Hi team,
>
> I want to execute a *LuceneQuery* that searches both a queryString(E.g.
> "station:Piccadilly*") as well as nearest station within .5 miles.(E.g.
> SpatialHelper.findWithin(lat, long, 0.5))
>
> In other words, is there any means of combining *luceneQuery1* &
> *luceneQuery2* and executing them as
> Collection<Station> nearestStations = *luceneQuery*.findValues();
>
> where luceneQuery = luceneQuery1 + luceneQuery2
>
> *LuceneQuery1*
> LuceneQuery<Long, Station> luceneQuery1 =
> luceneService
> .createLuceneQueryFactory()
> .setLimit(100)
> .create("stationNameIndex", "stations-region", queryString,
> "name");
>
> *LuceneQuery2*
> LuceneQuery<Long, Station> luceneQuery2 =
> luceneService
> .createLuceneQueryFactory()
> .create("stationNameIndex", "stations-region", index ->
> SpatialHelper.findWithin(-122.8515139, 45.5099231, 0.5);
>
> Regards
> Aj
>