Replace in elasticsearch query


(vallabh) #1

Dear All,

Can i use REPLACE function in elasticsearch query like mysql.

Mysql query:
select id,name from jos_artist_details where REPLACE(name, ' ', '')
= REPLACE('lady gaga',' ','');

Elastic search query:
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"name" => 'lady gaga'
)
)
)
)
),
"from" => 0,
"size" => 100000,
"sort" => array (
"_score"
)
)
);

Any suggestion is highly appreciated!!

Vallabh

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d0be8ab5-5759-4e32-a973-5733e72e0dbf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Alexander Reelsen) #2

Hey,

you could use a script field for this, if you really need to. However this
might be quite a performance killer (like it is in SQL) - data manipulation
should be done at index time, not at query time.

See
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html

--Alex

On Wed, Dec 4, 2013 at 10:31 AM, Vallabh Bothre vallabh.bothre@gmail.comwrote:

Dear All,

Can i use REPLACE function in elasticsearch query like mysql.

Mysql query:
select id,name from jos_artist_details where REPLACE(name, ' ', '')
= REPLACE('lady gaga',' ','');

Elastic search query:
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"name" => 'lady gaga'
)
)
)
)
),
"from" => 0,
"size" => 100000,
"sort" => array (
"_score"
)
)
);

Any suggestion is highly appreciated!!

Vallabh

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/d0be8ab5-5759-4e32-a973-5733e72e0dbf%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9knXgHs6iJM1Ga_kQkHQkp2aKB3r5WR_Qqw2bvV3h8tg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(vallabh) #3

Thanks Alex

On Wednesday, December 4, 2013 7:01:42 PM UTC+5:30, Alexander Reelsen wrote:

Hey,

you could use a script field for this, if you really need to. However this
might be quite a performance killer (like it is in SQL) - data manipulation
should be done at index time, not at query time.

See
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html

--Alex

On Wed, Dec 4, 2013 at 10:31 AM, Vallabh Bothre <vallabh...@gmail.com<javascript:>

wrote:

Dear All,

Can i use REPLACE function in elasticsearch query like mysql.

Mysql query:
select id,name from jos_artist_details where REPLACE(name, ' ', '')
= REPLACE('lady gaga',' ','');

Elastic search query:
$result = $es->search(array(
"query" => array(
"dis_max" => array(
"queries" => array(
0 => array(
"field" => array(
"name" => 'lady gaga'
)
)
)
)
),
"from" => 0,
"size" => 100000,
"sort" => array (
"_score"
)
)
);

Any suggestion is highly appreciated!!

Vallabh

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/d0be8ab5-5759-4e32-a973-5733e72e0dbf%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0d4f9a6f-3f69-4095-bc3f-be4be80b5ebf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4