Hi Erik,
you are spot on with your guess. I had reinserted my data but apparently
that does not reindex. Delete everything and re-enter was required.
Behaviour now seems to be as desired.
Thank you very much.
PS, thanks for pointing out that the !term is literal. Where can I find
that kind of information on the internet? I use the lucene syntax page
as my reference but it appears to be somewhat limited:
http://lucene.apache.org/java/2_9_1/queryparsersyntax.html
Kind regards,
Roland
Erik Hatcher wrote:
Roland -
Is it possible that you indexed with a different field type and then changed to "string"
without reindexing? A query on a string will only match literally the exact value (barring any
wildcard/regex syntax), so something is fishy with your example. Your query example was odd, not
sure if you meant it literally, but given the Word field name the query would be q={!term
f=Word}apple - maybe you thought "term" was meta, but it is meant literally here.
Erik
On Nov 3, 2011, at 04:45 , Roland Tollenaar wrote:
Hi Erik,
thanks for the response. I have ensured the type is string and that the field
is indexed. No luck though:
(Schema setting under solr/conf):
<field name="Word" type="string" indexed="true" stored="true" />
Query:
Word:apple
Desired result:
apple
Achieved Results:
apple, the red apple, pine-apple, etc, etc
I have also tried your other suggestion:
q={!" " f=Word}apple
(attmpting to eliminate any results with spaces)
But that just gives errors (from calling from the solr/admin query interface.
Am I doing something obviously wrong?
Thanks again,
Roland
It's certainly quite possible with Lucene/Solr. But you have to index >the field to accommodate it.
If you literally want an exact match >query, use the "string" field type and then issue a
term query. >q=field:value will work in simple cases (where the value has no spaces >or colons, or
other query parser syntax), but q={!term f=field}value is >the fail-safe way to do that.
Erik
Erik Hatcher wrote:
It's certainly quite possible with Lucene/Solr. But you have to index the field to
accommodate it. If you literally want an exact match query, use the "string"
field type and then issue a term query. q=field:value will work in simple cases (where
the value has no spaces or colons, or other query parser syntax), but q={!term
f=field}value is the fail-safe way to do that.
Erik
On Nov 2, 2011, at 07:08 , Roland Tollenaar wrote:
Hi,
I am trying to do a search that will only match exact words on a field.
I have read somewhere that this is not what SOLR is meant for but I am still
hoping that its possible.
This is an example of what I have tried (to exclude spaces) but the workaround
does not seem to work.
Word:apple NOT " "
What I am really looking for is the "=" operator in SQL (eg Word='apple') but I
cannot find its equivalent for lucene.
Thanks for the help.
Regards,
Roland