1

I've been playing around with creating a collection in Apache Solr via ColdFusion 9 from a database result set. I would like to do a search which would be as follows in SQL:

select * from events where eventName like 'Meet%'

In SQL this will match partially on a word and return the row. I am trying to do this using a Solr collection and <cfsearch> in CF like so:

<cfsearch collection="#myCollection#" criteria="Meet*" name="results" />

However I am not getting the data back unless I specify the full word, despite the use of the wildcard. The docs say the wildcard is not allowed at the start of the search but it doesn't say it's not allowed at the end. In fact for me it doesn't work anywhere!

<!--- No results -->
<cfsearch collection="#myCollection#" criteria="Meet*" name="results" /> 

<!--- No results -->
<cfsearch collection="#myCollection#" criteria="Meet*g" name="results" />

<!--- No results -->
<cfsearch collection="#myCollection#" criteria="Meeti?g" name="results" />

<!--- Yes - results! -->
<cfsearch collection="#myCollection#" criteria="Meeting" name="results" />

Has anyone implemented a wildcard Solr search using <cfsearch>? If so can you point me in the right direction on this please?

Ciaran Archer
  • 12,316
  • 9
  • 38
  • 55

2 Answers2

5

Try "meet*" rather than "Meet*". I've found that wildcards will only work with lower case strings, so whenever a search query contains an asterisk I LCase() the string before passing it to Solr.

CfSimplicity
  • 2,338
  • 15
  • 17
  • This is the answer! No wonder I was getting confusing results. I wish the docs would mention that - in fact I will post a comment there now. – Ciaran Archer Feb 24 '11 at 10:15
1

Have you had a look at this post about wildcard searching in Solr? As long as you are using the correct query parser, i.e. one that supports wildcard queries, then you should be able to do the 'Meet%' query using 'Meet*'.

Community
  • 1
  • 1
brent777
  • 3,369
  • 1
  • 26
  • 35