Hi, If adding PhraseQuery objects does not work, then using SpanNearQuery with slop 0 and order true for p1 and p2 should work (tried).
Dmitry On Thu, Apr 30, 2015 at 8:43 PM, Sujit Pal <sujit....@comcast.net> wrote: > Hi Vijay, > > I haven't tried this myself, but perhaps you could build the two phrases as > PhraseQueries and connect them up with a SpanQuery? Something like this > (using your original example). > > PhraseQuery p1 = new PhraseQuery(); > for (String word : "this is phrase 1".split()) { > ....p1.add(new Term("my_field", word)); > } > PhraseQuery p2 = new PhraseQuery(); > for (String word : "this is the second phrase".split()) { > ....p2.add(new Term("my_field", word)); > } > SpanQuery q = new SpanNearQuery(new SpanQuery[] {p1, p2}, 4, true); > > -sujit > > > On Thu, Apr 30, 2015 at 10:04 AM, Vijaya Narayana Reddy Bhoomi Reddy < > vijaya.bhoomire...@whishworks.com> wrote: > > > Thanks Rajani. > > > > I could get proximity search work for individual words. However, still > > could not make it work for two phrases, each containing more than a word. > > Also, results seem to be unexpected for proximity queries with wildcards. > > > > > > > > Thanks & Regards > > Vijay > > > > > > On 30 April 2015 at 15:19, Rajani Maski <rajani.ma...@lucidworks.com> > > wrote: > > > > > Hi Vijaya, > > > > > > I just quickly tried proximity search with the example set shipped with > > > solr 5 and it looked like working for me. > > > Perhaps, what you could is debug the query by enabling debugQuery=true. > > > > > > > > > Here are the steps that I tried.(Assuming you are on Solr 5. Though > this > > > term proximity functionality should work for 4.x versions too) > > > > > > 1. Go to solr5.0 downloaded folder and navigate to bin. > > > > > > Rajanis-MacBook-Pro:solr-5.0.0 rajanishivarajmaski$ bin/solr -e > > > techproducts > > > > > > 2. Execute the below query. The field "name" has value "Test with some > > > GB18030 encoded characters" and you search for name: "Test > GB18030"~10 > > > > > > http://localhost:8983/solr/techproducts/select?q=name: "Test > > > GB18030"~10&wt=json&indent=true > > > > > > Image : http://postimg.org/image/bjkbufsph/ > > > > > > > > > On Thu, Apr 30, 2015 at 7:14 PM, Vijaya Narayana Reddy Bhoomi Reddy < > > > vijaya.bhoomire...@whishworks.com> wrote: > > > > > > > I just tried with simple proximity search like "word1 word2" ~3 and > it > > is > > > > not working. Just wondering whether I have to make any configuration > > > > changes to solrconfig.xml to make proximity search work? > > > > > > > > Thanks > > > > Vijay > > > > > > > > > > > > On 30 April 2015 at 14:32, Vijaya Narayana Reddy Bhoomi Reddy < > > > > vijaya.bhoomire...@whishworks.com> wrote: > > > > > > > > > Hi, > > > > > > > > > > I have created my index with the default configurations. Now I am > > > trying > > > > > to use proximity search. However, I am bit not sure on the results > > and > > > > > where its going wrong. > > > > > > > > > > For example, I want to find two phrases "this is phrase one" and > > > another > > > > > phrase "this is the second phrase" with not more than a proximity > > > > distance > > > > > of 4 words in between them. The query syntax I am using is "(\"this > > is > > > > > phrase one\") (\"this is the second phrase\")"~4 > > > > > > > > > > However, the results I am getting are similar to OR operation. Can > > > anyone > > > > > please let me know whether the syntax is correct? > > > > > > > > > > Also, please let me know how to implement proximity search using > > SolrJ > > > > > Query API? > > > > > > > > > > Thanks & Regards > > > > > Vijay > > > > > > > > > > > > > -- > > > > The contents of this e-mail are confidential and for the exclusive > use > > of > > > > the intended recipient. If you receive this e-mail in error please > > delete > > > > it from your system immediately and notify us either by e-mail or > > > > telephone. You should not copy, forward or otherwise disclose the > > content > > > > of the e-mail. The views expressed in this communication may not > > > > necessarily be the view held by WHISHWORKS. > > > > > > > > > > > -- > > The contents of this e-mail are confidential and for the exclusive use of > > the intended recipient. If you receive this e-mail in error please delete > > it from your system immediately and notify us either by e-mail or > > telephone. You should not copy, forward or otherwise disclose the content > > of the e-mail. The views expressed in this communication may not > > necessarily be the view held by WHISHWORKS. > > > -- Dmitry Kan Luke Toolbox: http://github.com/DmitryKey/luke Blog: http://dmitrykan.blogspot.com Twitter: http://twitter.com/dmitrykan SemanticAnalyzer: www.semanticanalyzer.info