I would look at Query getFieldQuery(String field, String queryText) in QueryParser for inspiration.

feed the two strings, one at a time to the analyzer.

With the results from String1 do something like:

     List<SpanQuery> clauses = new ArrayList<SpanQuery>(v.size());
                   for (int i = 0; i < v.size(); i++) {
                       SpanQuery termQuery = new SpanTermQuery(new Term(
                                   field, v.get(i).termText()));
                       termQuery.setBoost(this.boost);
                       clauses.set(i, termQuery);
                   }

SpanNearQuery query = new SpanNearQuery((SpanQuery[]) clauses.toArray(
                               new SpanQuery[0]), slop, true);

Except first look for karl wettins FuzzySpanQuery in JIRA. Instead of a SpanTermQuery use that.

Now wrap this SpanNearQuery in a new SpanNearQuery with String2.

- Mark


Akanksha Baid wrote:
I have two strings -
String1 contains multiple words  &
String2 contains just 1 word

I need to search my index to find hits where String1 and String2 occur within a distance "slop = d" of each other. Order is important. Also, ideally I would like to do a fuzzy search on String1. Is there some way to do this without having to chop string1 into multiple terms and adding them to a SpanQuery[]?

Thanks for the help.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to