You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Nick Way <ni...@southeastpublishing.com> on 2017/06/06 08:00:04 UTC

I want "john smi" to find "john smith" in my custom "fullname_s" field

Hi - I have a Solr collection with a custom field "fullname_s" (a string).

I want "john smi" to find "john smith" (I lower-cased the names upon
indexing them)

I have tried

fullname_s:"john smi*"
fullname_s:john smi*
fullname_s:"john smi?"
fullname_s:john smi?


but nothing gives the expected result - am I missing something? I spent
hours on this one point yesterday so if anyone can please point me in the
right direction I'd be really grateful.

I'm using Solr with Adobe Coldfusion by the way but I think the principles
are the same.

Thank you!

Nick

Re: I want "john smi" to find "john smith" in my custom "fullname_s" field

Posted by Erik Hatcher <er...@gmail.com>.
Nick - try escaping the space, so that your query is q=fullname_s:john\ smi* 

However, whitespace and escaping is problematic.  There is a handy prefix query parser, so this would work on a string field with spaces:

    q={!prefix f=fullname_s}john smi

note no trailing asterisk on that one.   Even better, IMO, is to separate the query string from the query parser:

    q={!prefix f=fullname_s v=$qq}&qq=john smi

	Erik

----

Amrit - the issue with your example below is that q=fullname_s:john smi* parses “john” against fullname_s and “smi” as a prefix query against the default field, not likely fullname_s.   Check your parsed query to see exactly how it parsed.    It works for you because… magic!   (copyField * => _text_)




> On Jun 6, 2017, at 5:14 AM, Amrit Sarkar <sa...@gmail.com> wrote:
> 
> Nick,
> 
> "string" is a primitive data-type and the entire value of a field is
> indexed as single token. The regex matching happens against the tokens for
> text fields and against the full content for string fields. So once a piece
> of text is tokenized, there is no way to perform a regex query across word
> boundaries.
> 
> fullname_s:john smi* is working for me.
> 
> {
>  "responseHeader":{
>    "zkConnected":true,
>    "status":0,
>    "QTime":16,
>    "params":{
>      "q":"fullname_s:john smi*",
>      "indent":"on",
>      "wt":"json"}},
>  "response":{"numFound":1,"start":0,"maxScore":1.0,"docs":[
>      {
>        "id":"1",
>        "fullname_s":"john smith",
>        "_version_":1569446064473243648}]
>  }}
> 
> I am on Solr 6.5.0. What version you are on?
> 
> 
> Amrit Sarkar
> Search Engineer
> Lucidworks, Inc.
> 415-589-9269
> www.lucidworks.com
> Twitter http://twitter.com/lucidworks
> LinkedIn: https://www.linkedin.com/in/sarkaramrit2
> 
> On Tue, Jun 6, 2017 at 1:30 PM, Nick Way <ni...@southeastpublishing.com>
> wrote:
> 
>> Hi - I have a Solr collection with a custom field "fullname_s" (a string).
>> 
>> I want "john smi" to find "john smith" (I lower-cased the names upon
>> indexing them)
>> 
>> I have tried
>> 
>> fullname_s:"john smi*"
>> fullname_s:john smi*
>> fullname_s:"john smi?"
>> fullname_s:john smi?
>> 
>> 
>> but nothing gives the expected result - am I missing something? I spent
>> hours on this one point yesterday so if anyone can please point me in the
>> right direction I'd be really grateful.
>> 
>> I'm using Solr with Adobe Coldfusion by the way but I think the principles
>> are the same.
>> 
>> Thank you!
>> 
>> Nick
>> 


Re: I want "john smi" to find "john smith" in my custom "fullname_s" field

Posted by Amrit Sarkar <sa...@gmail.com>.
Nick,

"string" is a primitive data-type and the entire value of a field is
indexed as single token. The regex matching happens against the tokens for
text fields and against the full content for string fields. So once a piece
of text is tokenized, there is no way to perform a regex query across word
boundaries.

fullname_s:john smi* is working for me.

{
  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":16,
    "params":{
      "q":"fullname_s:john smi*",
      "indent":"on",
      "wt":"json"}},
  "response":{"numFound":1,"start":0,"maxScore":1.0,"docs":[
      {
        "id":"1",
        "fullname_s":"john smith",
        "_version_":1569446064473243648}]
  }}

I am on Solr 6.5.0. What version you are on?


Amrit Sarkar
Search Engineer
Lucidworks, Inc.
415-589-9269
www.lucidworks.com
Twitter http://twitter.com/lucidworks
LinkedIn: https://www.linkedin.com/in/sarkaramrit2

On Tue, Jun 6, 2017 at 1:30 PM, Nick Way <ni...@southeastpublishing.com>
wrote:

> Hi - I have a Solr collection with a custom field "fullname_s" (a string).
>
> I want "john smi" to find "john smith" (I lower-cased the names upon
> indexing them)
>
> I have tried
>
> fullname_s:"john smi*"
> fullname_s:john smi*
> fullname_s:"john smi?"
> fullname_s:john smi?
>
>
> but nothing gives the expected result - am I missing something? I spent
> hours on this one point yesterday so if anyone can please point me in the
> right direction I'd be really grateful.
>
> I'm using Solr with Adobe Coldfusion by the way but I think the principles
> are the same.
>
> Thank you!
>
> Nick
>