On 4/30/2014 2:29 PM, johnmu...@aol.com wrote: > My question is this: what Lucene search syntax will give meback result the > fastest? If my user is interestedin finding data within “title” and “owner” > fields only “doc_type” “DOC”, shouldI build my Lucene search syntax as: > > 1) skyfall ian fleming AND doc_type:DOC
If your default field is text, I'm fairly sure this will become equivalent to the following which is probably NOT what you want. Parentheses can be very important. text:skyfall OR text:ian OR (text:fleming AND doc_type:DOC) > 2) title:(skyfall OR ian OR fleming) owner:(skyfall OR ian OR fleming) AND > doc_type:DOC This kind of query syntax is probably what you should shoot for. Not from a performance perspective -- just from the perspective of making your queries completely correct. Note that the +/- syntax combined with parentheses is far more precise than using AND/OR/NOT. > 3) Something else I don't know about. The edismax query parser is very powerful. That might be something you're interested in. https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser > Of the 10 million documents I will be indexing, 80% will be of "doc_type" > PDF, and about 10% of type DOC, so please keep that in mind as a factor (if > that will mean anything in terms of which syntax I should use). For the most part, whatever general query format you choose to use will not matter very much. There are exceptions, but mostly Solr (Lucene) is smart enough to convert your query to an efficient final parsed format. Turn on the debugQuery parameterto see what it does with each query. Regardless of whether you use the standard lucene query parser or edismax, incorporate filter queries into your query constructing logic. Your second example above would be better to express like this, with the default operator set to OR. This uses both q and fq parameters: q=title:(skyfall ian fleming) owner:(skyfall ian fleming)&fq=doc_type:DOC https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-Thefq%28FilterQuery%29Parameter Thanks, Shawn