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 JZ <zh...@gmail.com> on 2013/07/03 16:59:26 UTC
Search for string ending with question mark
Hi all,
Currently, I am experimenting with the tokenizers.
Assume, I have the values: "2013?", "1900?", "87?".
I want to retrieve all values that end with the question mark as literal.
How do I need to define the <fieldType> in the schema.xml to allow for such
a query?
I assume it would be like: *\?
Is this possible in Lucene/Solr?
Cheers
Re: Search for string ending with question mark
Posted by JZ <zh...@gmail.com>.
Thanks! Unfortunately it is not working. I use Solr 3.6.2.
This is how I have defined the field type:
<fieldType name="textgen2" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
When I query for "*\?" I still get false positives, i.e. values that do not
end with a question mark.
Am I missing something very trivial?
Cheers
On Wed, Jul 3, 2013 at 5:28 PM, Jack Krupansky <ja...@basetechnology.com>wrote:
> Most tokenizers would treat "?" as punctuation - to be ignored. The white
> space tokenizer will preserve all punctuation.
>
> Or, use a raw string field ("string"/StrField).
>
> In either case, you would need to escape the "?" in the query parser (with
> a backslash) since it is a wildcard character.
>
> Yes, string_field:*\? should match any string field that ends with a "?".
>
> -- Jack Krupansky
>
> -----Original Message----- From: JZ
> Sent: Wednesday, July 03, 2013 10:59 AM
> To: solr-user@lucene.apache.org
> Subject: Search for string ending with question mark
>
>
> Hi all,
>
> Currently, I am experimenting with the tokenizers.
>
> Assume, I have the values: "2013?", "1900?", "87?".
>
> I want to retrieve all values that end with the question mark as literal.
>
> How do I need to define the <fieldType> in the schema.xml to allow for such
> a query?
>
> I assume it would be like: *\?
>
> Is this possible in Lucene/Solr?
>
> Cheers
>
Re: Search for string ending with question mark
Posted by Jack Krupansky <ja...@basetechnology.com>.
Most tokenizers would treat "?" as punctuation - to be ignored. The white
space tokenizer will preserve all punctuation.
Or, use a raw string field ("string"/StrField).
In either case, you would need to escape the "?" in the query parser (with a
backslash) since it is a wildcard character.
Yes, string_field:*\? should match any string field that ends with a "?".
-- Jack Krupansky
-----Original Message-----
From: JZ
Sent: Wednesday, July 03, 2013 10:59 AM
To: solr-user@lucene.apache.org
Subject: Search for string ending with question mark
Hi all,
Currently, I am experimenting with the tokenizers.
Assume, I have the values: "2013?", "1900?", "87?".
I want to retrieve all values that end with the question mark as literal.
How do I need to define the <fieldType> in the schema.xml to allow for such
a query?
I assume it would be like: *\?
Is this possible in Lucene/Solr?
Cheers