How to store email address and username without the part search

Hi,

I'm new to elasticsearch, and am having issues setting up document mapping,
i have set up multiple indexes, one per language, and have the same
document mapping set up per index (see below) i'm trying to set it up, so
the user can search for the username or email address as a whole, and not
allow them to do a part search of them, how can I achieve this?

Excuse the php :

'id' => array('type' => 'string', 'store' => 'yes', 'index' =>
'no', 'boost' => 1.0, 'include_in_all' => true),
'username' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'email_address' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'bio' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'first_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'last_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'company_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'active' => array('type' => 'boolean', 'store' => 'yes', 'index' =>
'no' , 'boost' => 1.0, 'include_in_all' => true),

--

Hi Paul,

What problem are you seeing with your mappings?

I see you've marked username and email_address as not_analyzed which will
mean they will be indexed as a single term, which seems to be the behaviour
you are after. Are you able to share some queries that are not working as
you'd hoped?

On Wednesday, November 14, 2012 5:35:37 AM UTC+13, paul.cdf wrote:

Hi,

I'm new to elasticsearch, and am having issues setting up document
mapping, i have set up multiple indexes, one per language, and have the
same document mapping set up per index (see below) i'm trying to set it up,
so the user can search for the username or email address as a whole, and
not allow them to do a part search of them, how can I achieve this?

Excuse the php :

'id' => array('type' => 'string', 'store' => 'yes', 'index' =>
'no', 'boost' => 1.0, 'include_in_all' => true),
'username' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'email_address' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'bio' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'first_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'last_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'company_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'active' => array('type' => 'boolean', 'store' => 'yes', 'index' =>
'no' , 'boost' => 1.0, 'include_in_all' => true),

--

If I do a search on an email address for example testing@hotmail.com by
using the query testing* , it's still found, i dont want it to be able to
be found unless someone types in the whole email address.

My Mapping is now set up as this

{"person":{"index_analyzer":"indexAnalyzerEnglish","search_analyzer":"searchAnalyzerEnglish","_all":{"auto_boost":true,"analyzer":"uax_url_email"},"properties":{"a":{"type":"boolean","index":"no","store":"yes"},"b":{"type":"string","include_in_all":true},"cn":{"type":"string","include_in_all":true},"ea":{"type":"string","boost":2.0,"index":"not_analyzed","include_in_all":true},"fn":{"type":"string","include_in_all":true},"id":{"type":"string","index":"no","store":"yes","include_in_all":true},"ln":{"type":"string","include_in_all":true},"un":{"type":"string","boost":2.0,"index":"not_analyzed","include_in_all":true}}}}

And my settings are as follows

{"english":{"settings":{"index.number_of_replicas":"1","index.analysis.filter.mySnowballEnglish.language":"English","index.analysis.analyzer.searchAnalyzerEnglish.type":"custom","index.analysis.analyzer.indexAnalyzerEnglish.tokenizer":"standard","index.analysis.analyzer.searchAnalyzerEnglish.tokenizer":"standard","index.analysis.analyzer.uax_url_email.tokenizer":"uax_url_email","index.analysis.analyzer.uax_url_email.filter.2":"stop","index.analysis.analyzer.uax_url_email.filter.1":"lowercase","index.analysis.analyzer.uax_url_email.filter.0":"standard","index.analysis.analyzer.indexAnalyzerEnglish.type":"custom","index.analysis.filter.mySnowballEnglish.type":"snowball","index.analysis.analyzer.searchAnalyzerEnglish.filter.2":"mySnowballEnglish","index.analysis.analyzer.searchAnalyzerEnglish.filter.1":"lowercase","index.analysis.analyzer.searchAnalyzerEnglish.filter.0":"standard","index.number_of_shards":"4","index.analysis.analyzer.indexAnalyzerEnglish.filter.1":"mySnowballEnglish","index.analysis.analyzer.indexAnalyzerEnglish.filter.0":"lowercase","index.version.created":"191199"}}}

is there something wrong with either?

On Tuesday, 13 November 2012 22:47:39 UTC, Chris Male wrote:

Hi Paul,

What problem are you seeing with your mappings?

I see you've marked username and email_address as not_analyzed which will
mean they will be indexed as a single term, which seems to be the behaviour
you are after. Are you able to share some queries that are not working as
you'd hoped?

On Wednesday, November 14, 2012 5:35:37 AM UTC+13, paul.cdf wrote:

Hi,

I'm new to elasticsearch, and am having issues setting up document
mapping, i have set up multiple indexes, one per language, and have the
same document mapping set up per index (see below) i'm trying to set it up,
so the user can search for the username or email address as a whole, and
not allow them to do a part search of them, how can I achieve this?

Excuse the php :

'id' => array('type' => 'string', 'store' => 'yes', 'index' =>
'no', 'boost' => 1.0, 'include_in_all' => true),
'username' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'email_address' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'bio' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'first_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'last_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'company_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'active' => array('type' => 'boolean', 'store' => 'yes', 'index'
=> 'no' , 'boost' => 1.0, 'include_in_all' => true),

--

Hi Paul,

On Thursday, November 15, 2012 5:30:01 AM UTC+13, paul.cdf wrote:

If I do a search on an email address for example tes...@hotmail.com<javascript:>by using the query testing* , it's still found, i dont want it to be able
to be found unless someone types in the whole email address.

So you're executing a wildcard query and matching the email address, when
you only want to match the email address when it's fully typed in? There's
not much ElasticSearch can do can to help you here. I recommend you
validate your query at the user input end and prevent any wildcard queries
from being executed against the email address field.

My Mapping is now set up as this

{"person":{"index_analyzer":"indexAnalyzerEnglish","search_analyzer":"searchAnalyzerEnglish","_all":{"auto_boost":true,"analyzer":"uax_url_email"},"properties":{"a":{"type":"boolean","index":"no","store":"yes"},"b":{"type":"string","include_in_all":true},"cn":{"type":"string","include_in_all":true},"ea":{"type":"string","boost":2.0,"index":"not_analyzed","include_in_all":true},"fn":{"type":"string","include_in_all":true},"id":{"type":"string","index":"no","store":"yes","include_in_all":true},"ln":{"type":"string","include_in_all":true},"un":{"type":"string","boost":2.0,"index":"not_analyzed","include_in_all":true}}}}

And my settings are as follows

{"english":{"settings":{"index.number_of_replicas":"1","index.analysis.filter.mySnowballEnglish.language":"English","index.analysis.analyzer.searchAnalyzerEnglish.type":"custom","index.analysis.analyzer.indexAnalyzerEnglish.tokenizer":"standard","index.analysis.analyzer.searchAnalyzerEnglish.tokenizer":"standard","index.analysis.analyzer.uax_url_email.tokenizer":"uax_url_email","index.analysis.analyzer.uax_url_email.filter.2":"stop","index.analysis.analyzer.uax_url_email.filter.1":"lowercase","index.analysis.analyzer.uax_url_email.filter.0":"standard","index.analysis.analyzer.indexAnalyzerEnglish.type":"custom","index.analysis.filter.mySnowballEnglish.type":"snowball","index.analysis.analyzer.searchAnalyzerEnglish.filter.2":"mySnowballEnglish","index.analysis.analyzer.searchAnalyzerEnglish.filter.1":"lowercase","index.analysis.analyzer.searchAnalyzerEnglish.filter.0":"standard","index.number_of_shards":"4","index.analysis.analyzer.indexAnalyzerEnglish.filter.1":"mySnowballEnglish","index.analysis.analyzer.indexAnalyzerEnglish.filter.0":"lowercase","index.version.created":"191199"}}}

is there something wrong with either?

On Tuesday, 13 November 2012 22:47:39 UTC, Chris Male wrote:

Hi Paul,

What problem are you seeing with your mappings?

I see you've marked username and email_address as not_analyzed which will
mean they will be indexed as a single term, which seems to be the behaviour
you are after. Are you able to share some queries that are not working as
you'd hoped?

On Wednesday, November 14, 2012 5:35:37 AM UTC+13, paul.cdf wrote:

Hi,

I'm new to elasticsearch, and am having issues setting up document
mapping, i have set up multiple indexes, one per language, and have the
same document mapping set up per index (see below) i'm trying to set it up,
so the user can search for the username or email address as a whole, and
not allow them to do a part search of them, how can I achieve this?

Excuse the php :

'id' => array('type' => 'string', 'store' => 'yes', 'index'
=> 'no', 'boost' => 1.0, 'include_in_all' => true),
'username' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'email_address' => array('type' => 'string', 'store' => 'no', 'index' =>
'not_analyzed', 'boost' => 2.0, 'include_in_all' => true),
'bio' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'first_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'last_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'company_name' => array('type' => 'string', 'store' => 'no', 'index' =>
'analyzed', 'boost' => 1.0, 'include_in_all' => true),
'active' => array('type' => 'boolean', 'store' => 'yes', 'index'
=> 'no' , 'boost' => 1.0, 'include_in_all' => true),

--

Thats great, thanks!

--