Hyphen search with wildcard '*' and normal serach

Hi All,

We are stuck in a situation where we need to search exact hyphen query and
others as wildcard query. We have 3 document type in our index
customer,quotation, and devices respectively. We are allowing user to
serach on minimum 4 characters hence we need to use wildcard.

The problem is quotation number contains hyphen "-" and we have to search
the complete data for e.g. "QNMP-1900" should not be searched as QNMP and
1900. That means if I search for "QNMP-19" then is should search for all
records start with QNMP-19.

Rest search query should also works with wildcard. I have tried keyword
analyzer, not_analyzed and token but no luck. I tried query_string and text
query but the result is breaking string based on hyphen.

Any help would be highly appreciated.

Thanks.

--

Have you looked at word delimiter filter
http://www.elasticsearch.org/guide/reference/index-modules/analysis/word-delimiter-tokenfilter.html?

On Fri, Dec 7, 2012 at 4:03 PM, aps pushkardkumar@gmail.com wrote:

Hi All,

We are stuck in a situation where we need to search exact hyphen query and
others as wildcard query. We have 3 document type in our index
customer,quotation, and devices respectively. We are allowing user to
serach on minimum 4 characters hence we need to use wildcard.

The problem is quotation number contains hyphen "-" and we have to search
the complete data for e.g. "QNMP-1900" should not be searched as QNMP and
1900. That means if I search for "QNMP-19" then is should search for all
records start with QNMP-19.

Rest search query should also works with wildcard. I have tried keyword
analyzer, not_analyzed and token but no luck. I tried query_string and text
query but the result is breaking string based on hyphen.

Any help would be highly appreciated.

Thanks.

--

--
Spica Framework: http://code.google.com/p/spica
http://www.twitter.com/pcdinh
http://groups.google.com/group/phpvietnam

--

I tried it but couldn't find the proper settings to search hyphen.

On Friday, 7 December 2012 11:07:13 UTC+2, pcdinh wrote:

Have you looked at word delimiter filter
http://www.elasticsearch.org/guide/reference/index-modules/analysis/word-delimiter-tokenfilter.html?

On Fri, Dec 7, 2012 at 4:03 PM, aps <pushka...@gmail.com <javascript:>>wrote:

Hi All,

We are stuck in a situation where we need to search exact hyphen query
and others as wildcard query. We have 3 document type in our index
customer,quotation, and devices respectively. We are allowing user to
serach on minimum 4 characters hence we need to use wildcard.

The problem is quotation number contains hyphen "-" and we have to search
the complete data for e.g. "QNMP-1900" should not be searched as QNMP and
1900. That means if I search for "QNMP-19" then is should search for all
records start with QNMP-19.

Rest search query should also works with wildcard. I have tried keyword
analyzer, not_analyzed and token but no luck. I tried query_string and text
query but the result is breaking string based on hyphen.

Any help would be highly appreciated.

Thanks.

--

--
Spica Framework: http://code.google.com/p/spica
http://www.twitter.com/pcdinh
http://groups.google.com/group/phpvietnam

--

I cannot think of a reason why indexing this data as not analyzed and
searching with wildcard wouldn't work for you. Could you change this
gist https://gist.github.com/4234377 to demonstrate your use case?

On Friday, December 7, 2012 4:18:05 AM UTC-5, aps wrote:

I tried it but couldn't find the proper settings to search hyphen.

On Friday, 7 December 2012 11:07:13 UTC+2, pcdinh wrote:

Have you looked at word delimiter filter
http://www.elasticsearch.org/guide/reference/index-modules/analysis/word-delimiter-tokenfilter.html?

On Fri, Dec 7, 2012 at 4:03 PM, aps pushka...@gmail.com wrote:

Hi All,

We are stuck in a situation where we need to search exact hyphen query
and others as wildcard query. We have 3 document type in our index
customer,quotation, and devices respectively. We are allowing user to
serach on minimum 4 characters hence we need to use wildcard.

The problem is quotation number contains hyphen "-" and we have to
search the complete data for e.g. "QNMP-1900" should not be searched as
QNMP and 1900. That means if I search for "QNMP-19" then is should search
for all records start with QNMP-19.

Rest search query should also works with wildcard. I have tried keyword
analyzer, not_analyzed and token but no luck. I tried query_string and text
query but the result is breaking string based on hyphen.

Any help would be highly appreciated.

Thanks.

--

--
Spica Framework: http://code.google.com/p/spica
http://www.twitter.com/pcdinh
http://groups.google.com/group/phpvietnam

--

If I understand the problem your searches for XXX-999 are being tokenized into two separate tokens? The standard tokenizer will do that, I believe I use the whitespace tokenizer to avoid that issue.

I am using global search where not_analyzed required term query. As I
specified I have 3 document type and I am searching on all.
Please check the query which I am using directly on index.

{

"from": "0",

"size": "10",

"query": {

"query_string": {

  "default_field": "_all",

  "default_operator": "AND",

  "analyze_wildcard": true,

  "query": "QNAM-45*"

}

}

}

Now in this query, search result are giving me result starts with QNAM and
45 both. The document type is set to default.

On Friday, 7 December 2012 18:20:57 UTC+2, Igor Motov wrote:

I cannot think of a reason why indexing this data as not analyzed and
searching with wildcard wouldn't work for you. Could you change this gist
https://gist.github.com/4234377 to demonstrate your use case?

On Friday, December 7, 2012 4:18:05 AM UTC-5, aps wrote:

I tried it but couldn't find the proper settings to search hyphen.

On Friday, 7 December 2012 11:07:13 UTC+2, pcdinh wrote:

Have you looked at word delimiter filter
http://www.elasticsearch.org/guide/reference/index-modules/analysis/word-delimiter-tokenfilter.html?

On Fri, Dec 7, 2012 at 4:03 PM, aps pushka...@gmail.com wrote:

Hi All,

We are stuck in a situation where we need to search exact hyphen query
and others as wildcard query. We have 3 document type in our index
customer,quotation, and devices respectively. We are allowing user to
serach on minimum 4 characters hence we need to use wildcard.

The problem is quotation number contains hyphen "-" and we have to
search the complete data for e.g. "QNMP-1900" should not be searched as
QNMP and 1900. That means if I search for "QNMP-19" then is should search
for all records start with QNMP-19.

Rest search query should also works with wildcard. I have tried keyword
analyzer, not_analyzed and token but no luck. I tried query_string and text
query but the result is breaking string based on hyphen.

Any help would be highly appreciated.

Thanks.

--

--
Spica Framework: http://code.google.com/p/spica
http://www.twitter.com/pcdinh
http://groups.google.com/group/phpvietnam

--

This query is searching the _all field which by default combines all fields
in your documents into a single field which is analyzed by the default
analyzer. You need to search individual fields (not _all) for the field
specific analyzer to be applied.

On Monday, December 10, 2012 2:54:15 AM UTC-5, aps wrote:

I am using global search where not_analyzed required term query. As I
specified I have 3 document type and I am searching on all.
Please check the query which I am using directly on index.

{

"from": "0",

"size": "10",

"query": {

"query_string": {

  "default_field": "_all",

  "default_operator": "AND",

  "analyze_wildcard": true,

  "query": "QNAM-45*"

}

}

}

Now in this query, search result are giving me result starts with QNAM and
45 both. The document type is set to default.

On Friday, 7 December 2012 18:20:57 UTC+2, Igor Motov wrote:

I cannot think of a reason why indexing this data as not analyzed and
searching with wildcard wouldn't work for you. Could you change this gist
https://gist.github.com/4234377 to demonstrate your use case?

On Friday, December 7, 2012 4:18:05 AM UTC-5, aps wrote:

I tried it but couldn't find the proper settings to search hyphen.

On Friday, 7 December 2012 11:07:13 UTC+2, pcdinh wrote:

Have you looked at word delimiter filter
http://www.elasticsearch.org/guide/reference/index-modules/analysis/word-delimiter-tokenfilter.html?

On Fri, Dec 7, 2012 at 4:03 PM, aps pushka...@gmail.com wrote:

Hi All,

We are stuck in a situation where we need to search exact hyphen query
and others as wildcard query. We have 3 document type in our index
customer,quotation, and devices respectively. We are allowing user to
serach on minimum 4 characters hence we need to use wildcard.

The problem is quotation number contains hyphen "-" and we have to
search the complete data for e.g. "QNMP-1900" should not be searched as
QNMP and 1900. That means if I search for "QNMP-19" then is should search
for all records start with QNMP-19.

Rest search query should also works with wildcard. I have tried
keyword analyzer, not_analyzed and token but no luck. I tried query_string
and text query but the result is breaking string based on hyphen.

Any help would be highly appreciated.

Thanks.

--

--
Spica Framework: http://code.google.com/p/spica
http://www.twitter.com/pcdinh
http://groups.google.com/group/phpvietnam

--