Hi! I have a content type "product", in wich I have a taxonomy term field of vocabulary "product_avaliability"(terms: avaliable (tid=84), not avaliable(tid=85)). I need the block "More like this" to display only nodes with value "avalible" for the field avaliability.
I tried such queries :
field_product_avaliability:avaliable
field_product_avaliability:84
avaliable
84
But the block doesn't show results.
Is there any documentation about the query language in Apache Solr Integration module? Any suggestions on the right query in my case?
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 1175218-16.patch | 1.33 KB | janchojnacki |
| #15 | 1175218-15.patch | 1.29 KB | jpmckinney |
| #8 | 1175218.patch | 1.15 KB | jpmckinney |
Comments
Comment #1
khiminrm commentedI have noticed an error in Recent log messages:
"400" Status: Bad Request: Bad RequestApache Tomcat/6.0.24 - Error report
HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse ':"field_product_availability:84"': Encountered " ":" ": "" at line 1, column 0.
Was expecting one of:
<NOT> ...
"+" ...
"-" ...
"(" ...
"*" ...
<QUOTED> ...
<TERM> ...
<PREFIXTERM> ...
<WILDTERM> ...
"[" ...
"{" ...
<NUMBER> ...
<TERM> ...
"*" ...
Any ideas?
Comment #2
khiminrm commentedMaybe the problem is in ':' added by module before my query?
Comment #3
vabue commentedsubscribe
Comment #4
khiminrm commentedComment #5
pwolanin commentedYes, ":" is a special character in lucene syntax.
The field names in the index DO NOT match the field names in the DB, so not of your filters above will work.
However, the simple filter
tid:84should work.Comment #6
pwolanin commentedComment #7
khiminrm commentedSorry, but the filter tid:84 doesn't work and I have the same error in Recent log messages:
"400" Status: Bad Request: Bad RequestApache Tomcat/6.0.24 - Error report HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse ':"tid:84"': Encountered " ":" ": "" at line 1, column 0.
....
Comment #8
jpmckinney commentedI think khiminrm is saying that the apachesolr module is inserting the ":". And I think it is due to
in apachesolr_mlt_suggestions. Fixed in patch.
Comment #9
pwolanin commentedMaybe we need some other cleanup of that MLT code too?
For the custom search pages I think it's taking a comma-separated list.
Comment #10
jpmckinney commentedWouldn't it work as-is if it were a space-separated list instead?
Comment #11
pwolanin commentedNo, since you can have a query with e.g. (X OR Y) groupings that contain spaces, or range queries with spaces.
Comment #12
khiminrm commentedComment #13
khiminrm commentedComment #14
khiminrm commentedI've aplied the patch, inputed tid:84 in the Additioanl Query field. The error message doesn't appear. But the block 'More like this' doesn't show anything.
Comment #15
jpmckinney commented@pwolanin: K. It occurs to me that if there is a range query anywhere in the string, we should not double quote. Included that fix in the patch.
@khiminrm: Did you enable the Solr filter for the taxonomy product_availability?
Comment #16
khiminrm commented@jpmckinney: Yes, I enabled filter for the taxonomy product_availability in the block settings. I even tried to enable filter "All taxonomy term names". After aplying the new patch - no results with filter
tid:84. Withouttid:84the block shows links to the nodes with tid 84 or tid 85. My nodes have other terms from different vocabularies, not just 84 or 85 from vocabulary Availability. Maybe the problem is in this?I tried facet filter block for vocabulary Availability in site's search results and It worked fine.
Comment #17
jpmckinney commentedIt sounds like there are more bugs in the "more like this" feature that we need to fix. I don't have time to look into it right now, though.
Comment #18
nick_vhComment #19
janchojnacki commentedAfter changing
to this:
It was working for me, in addition to patch
Comment #20
janchojnacki commentedSo, I upload valid patch for me. Unless somebody can tell me why there are needed quotation marks in
$filter['#value'] = '"' . $filter['#value'] . '"';Comment #21
nick_vhThis seems wrong to me?
Are you sure the exclude has to appear after the local parameter?
Also, I don't see the need in changing these regular expressions? If the only thing you want is to remove the name and only set the value you shouldn't need those changes right?
Comment #22
blazindrop commentedI had the same issue today with our related content block (powered by MLT) was bringing content in from other sites (we have one index for all sites). The same error was raised as in #1.
I stumbled upon this issue after reading through some code and see there was a @todo for handling comma-separated custom filters. Here's my initial thought:
Certain fields in SOLR require quotes (like string) whereas text fields don't (if you're doing a search and don't want a literal match). If the field you're filtering by requires quotes, just place them into the custom filter input box vs. fussing with a regex on the code side.
Negation logic can be added to the code above without much effort.
My two (maybe only one, heh) cents....
Comment #23
nick_vhCould you please make this a real patch? And also describe a test case where the original code fails and the modified one succeeds?
Comment #24
nick_vhComment #25
kevinquillen commentedSame issue, tried to add a filter from the MLT config to show results only for date created in a certain range (which is on the description in the form field). No matter what I enter, no results come back, and the server returns a ''bad request'' error from including the ds_created:[DATE TO DATE] filter. If I remove it, it works fine.
Comment #26
jason_purdy commentedI'm also running into this issue. I have a custom field in my solr index and whenever I try to filter based on the field, it creates a bad request because of the colon at the beginning.