Exact phrase match question. (I know, another one)

I seem to be having a problem getting an exact phrase match to work if
it has a space in it.

I am using a multi-map field defined as:

VendorName: {
type: multi_field
fields: {
VendorName: {
type: string
}
exact: {
include_in_all: false
analyzer: exact_match
type: string
}
}

The "exact_match" analyzer is defined as:

index.analysis.analyzer.exact_match.type: custom
index.analysis.analyzer.exact_match.filter: lowercase
index.analysis.analyzer.exact_match.tokenizer: keyword

I am doing this because this needs to be case insensitive.

I have double checked this analyzer with:
curl -XGET 'localhost:9200/test/_analyze?analyzer=exact_match' -d
'This-is a test'

And the response is:
{"tokens":[{"token":"this-is a test","start_offset":0,"end_offset":
14,"type":"word","position":1}]}'
which is what I expect.

I am building the query like this:

        String exactString = "\"this-is a\"";

        QueryStringQueryBuilder exactQuery =

QueryBuilders.queryString(exactString)
.defaultOperator(Operator.AND);

        exactQuery.field("VendorName.exact");
        filter = FilterBuilders.queryFilter(exactQuery);

        AndFilterBuilder filters = new AndFilterBuilder();
        filter.add(filter);
        QueryBuilders.constantScoreQuery(filters);

I am building the And filters this way, because we can have rather
complex searching, however, in this case, even just this one entry
still doesn't work.

I have tried autoGeneratePhraseQueries() but that doesn't seem to do
anything, so I am adding the "" myself.

The search performs flawlessly for any phrase I use, as long as it
doesn't include a space. For instance, a "this-is" search works fine.

I have tried many different combinations of options, and I do believe
this current configuration should work.

I am using version 0.19.4 in this test.

Thanks for your help,

Tom

The name of the field should be simply "exact", not
"VendorName.exact". You should also perhaps use a termQuery and not a
queryString (lowercasing the query yourself.

On Tue, Jun 12, 2012 at 6:19 AM, Tom Tayon tomtayon@gmail.com wrote:

I seem to be having a problem getting an exact phrase match to work if
it has a space in it.

I am using a multi-map field defined as:

VendorName: {
type: multi_field
fields: {
VendorName: {
type: string
}
exact: {
include_in_all: false
analyzer: exact_match
type: string
}
}

The "exact_match" analyzer is defined as:

index.analysis.analyzer.exact_match.type: custom
index.analysis.analyzer.exact_match.filter: lowercase
index.analysis.analyzer.exact_match.tokenizer: keyword

I am doing this because this needs to be case insensitive.

I have double checked this analyzer with:
curl -XGET 'localhost:9200/test/_analyze?analyzer=exact_match' -d
'This-is a test'

And the response is:
{"tokens":[{"token":"this-is a test","start_offset":0,"end_offset":
14,"type":"word","position":1}]}'
which is what I expect.

I am building the query like this:

       String exactString = "\"this-is a\"";

       QueryStringQueryBuilder exactQuery =

QueryBuilders.queryString(exactString)
.defaultOperator(Operator.AND);

       exactQuery.field("VendorName.exact");
       filter = FilterBuilders.queryFilter(exactQuery);

       AndFilterBuilder filters = new AndFilterBuilder();
       filter.add(filter);
       QueryBuilders.constantScoreQuery(filters);

I am building the And filters this way, because we can have rather
complex searching, however, in this case, even just this one entry
still doesn't work.

I have tried autoGeneratePhraseQueries() but that doesn't seem to do
anything, so I am adding the "" myself.

The search performs flawlessly for any phrase I use, as long as it
doesn't include a space. For instance, a "this-is" search works fine.

I have tried many different combinations of options, and I do believe
this current configuration should work.

I am using version 0.19.4 in this test.

Thanks for your help,

Tom

Ok, I will look into the termQuery.

I need to use VendorName.exact, because I don't also want the search
to look into other fields I have, i.e. "Address". I need field
specific searching.

Thanks

On Jun 12, 12:18 pm, Ivan Brusic i...@brusic.com wrote:

The name of the field should be simply "exact", not
"VendorName.exact". You should also perhaps use a termQuery and not a
queryString (lowercasing the query yourself.

On Tue, Jun 12, 2012 at 6:19 AM, Tom Tayon tomta...@gmail.com wrote:

I seem to be having a problem getting an exact phrase match to work if
it has a space in it.

I am using a multi-map field defined as:

VendorName: {
type: multi_field
fields: {
VendorName: {
type: string
}
exact: {
include_in_all: false
analyzer: exact_match
type: string
}
}

The "exact_match" analyzer is defined as:

index.analysis.analyzer.exact_match.type: custom
index.analysis.analyzer.exact_match.filter: lowercase
index.analysis.analyzer.exact_match.tokenizer: keyword

I am doing this because this needs to be case insensitive.

I have double checked this analyzer with:
curl -XGET 'localhost:9200/test/_analyze?analyzer=exact_match' -d
'This-is a test'

And the response is:
{"tokens":[{"token":"this-is a test","start_offset":0,"end_offset":
14,"type":"word","position":1}]}'
which is what I expect.

I am building the query like this:

       String exactString = "\"this-is a\"";
       QueryStringQueryBuilder exactQuery =

QueryBuilders.queryString(exactString)
.defaultOperator(Operator.AND);

       exactQuery.field("VendorName.exact");
       filter = FilterBuilders.queryFilter(exactQuery);
       AndFilterBuilder filters = new AndFilterBuilder();
       filter.add(filter);
       QueryBuilders.constantScoreQuery(filters);

I am building the And filters this way, because we can have rather
complex searching, however, in this case, even just this one entry
still doesn't work.

I have tried autoGeneratePhraseQueries() but that doesn't seem to do
anything, so I am adding the "" myself.

The search performs flawlessly for any phrase I use, as long as it
doesn't include a space. For instance, a "this-is" search works fine.

I have tried many different combinations of options, and I do believe
this current configuration should work.

I am using version 0.19.4 in this test.

Thanks for your help,

Tom