Thanks a lot Erick, your suggestion on using similarity will work great; I wasn't aware you could define similarity on a field by field basis until now, and that solution works perfectly.
Sorry what I said was a little misleading. I should have said "I don't want it to issue phrase queries to that specific field ever, because it has positions turned off and so phrase queries cause exceptions". Because I DO want to run phrase queries on the "title" data, I just have another field for that. The problem is the one described here: http://opensourceconnections.com/blog/2014/12/08/title-search-when-relevancy-is-only-skin-deep/ It still seems a bit off that you can't use an omitTermFreqAndPositions field with edismax's qf; but I can't think of a situation that defining a custom similarity wouldn't be the right solution. Thanks again, Ryan On Wed, Apr 8, 2015 at 5:29 PM, Erick Erickson <erickerick...@gmail.com> wrote: > Ryan: > > bq: I don't want it to issue phrase queries to that field ever > > This is one of those requirements that you'd have to enforce at the > app layer. Having Solr (or Lucene) enforce a rule like this for > everyone would be terrible. > > So if you're turning off TF but also saying title is "one of the > primary components of score". Since TF in integral to calculating > scores, I'm not quite sure what that means. > > You could write a custom similarity class that returns whatever you > want (1.0 comes to mind) from the tf() method. > > Best, > Erick > > On Wed, Apr 8, 2015 at 4:50 PM, Ryan Josal <rjo...@gmail.com> wrote: > > Thanks for your thought Shawn, I don't think fq will be helpful here. > The > > field for which I want to turn TF off is "title", which is actually one > of > > the primary components of score, so I really need it in qf. I just don't > > want the TF portion of the score for that field only. I don't want it to > > issue phrase queries to that field ever, but if the user quotes > something, > > it does, and I don't know how to make it stop. To me it seems > potentially > > more appropriate to send that to the pf fields, although I can think of a > > couple good reasons to put it against qf. That's fine as long as it > > doesn't try to build a phrase query against a no TF no pos field. > > > > Ryan > > > > On Wednesday, April 8, 2015, Shawn Heisey <apa...@elyograg.org> wrote: > > > >> On 4/8/2015 5:06 PM, Ryan Josal wrote: > >> > The error: > >> > IllegalStateException: field "foo" indexed without position data; > cannot > >> > run PhraseQuery. > >> > > >> > It would actually be ok for us to index position data but there isn't > an > >> > option for that without term frequencies. No TF is important for us > when > >> > it comes to searching product titles. > >> > > >> > I should say that only a small fraction of user queries contained > quoted > >> > phrases that trigger this error, so it works much of the time, but > we'd > >> > also like to continue supporting user quoted phrase queries. > >> > > >> > So how can I index a field without TF and use it in edismax qf? > >> > >> If you omit positions, you can't do phrase queries. As far as I know, > >> there is no option in Solr to omit only frequencies and not positions. > >> > >> I think there is a way that you can achieve what you want, though. What > >> you are looking for is filters. The fq parameter (filter query) will > >> restrict the result set to only entries that match the query, but will > >> not affect the relevancy score *at all*. Here is an example of a filter > >> query that restricts the results to items that are in stock, assuming > >> you have the appropriate schema: > >> > >> fq=inStock:true > >> > >> Queries specified in fq will default to the lucene query parser, but you > >> can override that if you need to. This query would be equivalent to the > >> previous one, but it would be parsed using edismax: > >> > >> fq={!edismax}inStock:true > >> > >> Here's another example of a useful filter, using yet another query > parser: > >> > >> fq={!terms f=userId}bob,alice,susan > >> > >> Remember, the reason I have suggested filters is that they do not > >> influence score. > >> > >> > >> > https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters#CommonQueryParameters-Thefq%28FilterQuery%29Parameter > >> > >> Thanks, > >> Shawn > >> > >> >