Optimize Elastic Search queryElasticsearch get a selection of predefined types as result in one querymapping social relation elasticsearchElasticsearch 5.0.2 failed to search for keywordElasticsearch: The full-text search does not workelasticsearch 5.2 sorting with ICU plugin needs fielddata = true?How to get “related documents” in a query in Elasticearch?Elasticsearch Auto complete using ngramHow to aggregate on elasticsearch field of type string which includes a slash (/)Elasticsearch synonyms giving no resultsElastic Search Aggregation Query of multiple levels optimization
Short Story: Cold War setting. In orbit, two astronauts decide whether to launch nuclear counter strike ("MAD" scenario). Twist at end
Why don't modern jet engines use forced exhaust mixing?
Trying to understand how Digital Certificates and CA are indeed secure
Vegetarian dishes on Russian trains (European part)
Why do we use low resistance cables to minimize power losses?
What should I do with the stock I own if I anticipate there will be a recession?
Parse a simple key=value config file in C
Did Michelle Obama have a staff of 23; and Melania have a staff of 4?
Do I need to start off my book by describing the character's "normal world"?
Reducing contention in thread-safe LruCache
How to render "have ideas above his station" into German
Can anybody tell me who this Pokemon is?
How to train a replacement without them knowing?
Quick destruction of a helium filled airship?
Adjective or adverb before another adjective
How to prevent criminal gangs from making/buying guns?
Are there any OR challenges that are similar to kaggle's competitions?
How could Tony Stark wield the Infinity Nano Gauntlet - at all?
Expressing a chain of boolean ORs using ILP
What is the opposite of "hunger level"?
How do I answer an interview question about how to handle a hard deadline I won't be able to meet?
Why can't I see 1861 / 1871 census entries on Freecen website when I can see them on Ancestry website?
Photoshop older default brushes
What's a good pattern to calculate a variable only when it is used the first time?
Optimize Elastic Search query
Elasticsearch get a selection of predefined types as result in one querymapping social relation elasticsearchElasticsearch 5.0.2 failed to search for keywordElasticsearch: The full-text search does not workelasticsearch 5.2 sorting with ICU plugin needs fielddata = true?How to get “related documents” in a query in Elasticearch?Elasticsearch Auto complete using ngramHow to aggregate on elasticsearch field of type string which includes a slash (/)Elasticsearch synonyms giving no resultsElastic Search Aggregation Query of multiple levels optimization
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have recently added elasticsearch as search engine for a project, it's an ecommerce structure model, and i use it to load categories, manufacturers etc.
The queries typically run very fast around 200ms which is pretty good considering the number products i have as on some projects i have more than 1 milion products.
However in some cases, like on a simple category page where i have around 550k products in that category page, the query takes around 500ms, i am wondering if i can optimize it to be faster.
Please not that i have aggregations and more filters added in the query depending on the options the customer selects, but for optimizing purposes i have removed them as i have the same loading speed with or without them.
This is the query which in that particular case takes around 500-600 ms
Array
(
[size] => 48
[from] => 0
[sort] => Array
(
[date_upd] => Array
(
[order] => desc
)
)
[query] => Array
(
[bool] => Array
(
[filter] => Array
(
[0] => Array
(
[term] => Array
(
[id_product_categories] => 38231
)
)
)
)
)
)
The elasticsearch index structure is as follows:
$data = array(
'settings' =>
array(
'number_of_shards' => 1,
'number_of_replicas' => 0,
'analysis' => $analysis,
'index' => array(
'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),
'sort.order' => array('desc','desc','desc','desc')
)
),
'mappings' => array(
'product' => array(
//'type' => 'product',
'_all' => array( 'enabled' => false),
'properties' => array
(
'id_product' => array(
'type' => 'integer'),
'id_image' =>array(
'type' => 'integer',
'null_value' => 0
),
'id_supplier' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_manufacturer' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_color' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'rating' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'id_default_category' => array(
'type' => 'integer',
'null_value' => 0
),
'popularity' => array(
'type' => 'integer',
'null_value' => 0
),
'reduction_percent' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'is_reduced' => array(
'type' => 'boolean'
),
'reference' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'image_cover' => array(
'type' => 'keyword',
'index' => false,
),
'image_title' => array(
'type' => 'keyword',
'index' => false,
),
'product_link_title' => array(
'type' => 'keyword',
'index' => false,
),
'price' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'old_price' => array(
'type' => 'float',
'null_value' => 0
),
'id_product_categories' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'date_add' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss',
'index' => true
),
'date_upd' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss'
),
'product_name' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_heading' => array(
'type' => 'keyword',
"index" => false
),
/*
'product_description' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
*/
'product_color' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_categories' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_manufacturer' => array(
'type' => 'text',
),
'product_supplier' => array(
'type' => 'text'
),
'product_link' => array(
'type' => 'keyword',
'index' => false
)
)
)
)
);
|
show 1 more comment
I have recently added elasticsearch as search engine for a project, it's an ecommerce structure model, and i use it to load categories, manufacturers etc.
The queries typically run very fast around 200ms which is pretty good considering the number products i have as on some projects i have more than 1 milion products.
However in some cases, like on a simple category page where i have around 550k products in that category page, the query takes around 500ms, i am wondering if i can optimize it to be faster.
Please not that i have aggregations and more filters added in the query depending on the options the customer selects, but for optimizing purposes i have removed them as i have the same loading speed with or without them.
This is the query which in that particular case takes around 500-600 ms
Array
(
[size] => 48
[from] => 0
[sort] => Array
(
[date_upd] => Array
(
[order] => desc
)
)
[query] => Array
(
[bool] => Array
(
[filter] => Array
(
[0] => Array
(
[term] => Array
(
[id_product_categories] => 38231
)
)
)
)
)
)
The elasticsearch index structure is as follows:
$data = array(
'settings' =>
array(
'number_of_shards' => 1,
'number_of_replicas' => 0,
'analysis' => $analysis,
'index' => array(
'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),
'sort.order' => array('desc','desc','desc','desc')
)
),
'mappings' => array(
'product' => array(
//'type' => 'product',
'_all' => array( 'enabled' => false),
'properties' => array
(
'id_product' => array(
'type' => 'integer'),
'id_image' =>array(
'type' => 'integer',
'null_value' => 0
),
'id_supplier' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_manufacturer' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_color' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'rating' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'id_default_category' => array(
'type' => 'integer',
'null_value' => 0
),
'popularity' => array(
'type' => 'integer',
'null_value' => 0
),
'reduction_percent' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'is_reduced' => array(
'type' => 'boolean'
),
'reference' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'image_cover' => array(
'type' => 'keyword',
'index' => false,
),
'image_title' => array(
'type' => 'keyword',
'index' => false,
),
'product_link_title' => array(
'type' => 'keyword',
'index' => false,
),
'price' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'old_price' => array(
'type' => 'float',
'null_value' => 0
),
'id_product_categories' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'date_add' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss',
'index' => true
),
'date_upd' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss'
),
'product_name' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_heading' => array(
'type' => 'keyword',
"index" => false
),
/*
'product_description' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
*/
'product_color' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_categories' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_manufacturer' => array(
'type' => 'text',
),
'product_supplier' => array(
'type' => 'text'
),
'product_link' => array(
'type' => 'keyword',
'index' => false
)
)
)
)
);
Are you sure that is a query execution time, but not data fetching time? If your query returns 550K items that could just take long time to pass all data. Try to limit results to confirm if that is the case
– Alex
Mar 27 at 13:09
@Alex I am certain that is not the fetching time, it only returns 48 elements, i have size => 48 at the beginning of the query, see the example above. There are 550k total products in the query (total hits)
– Pepelea Razvan Ionut
Mar 27 at 13:40
Anyone can help with this?
– Pepelea Razvan Ionut
Mar 28 at 18:45
I don't have Elastic sever to test at the moment. But just a guess, extend yoursettings=>'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),withid_product_categories
– Alex
Mar 28 at 19:05
If this is your actual query (I don't see the aggregation part). Atermquery should be really fast -- but you're wrapping it inside afilterso ES will cache it. Normally having a cache is really good, but if it's trying to fit in your most expensive query ... maybe not. You can check if it's still 500ms if you just runquery: term: [id_product_categories] : value : "38231"
– Tessmore
Mar 28 at 23:45
|
show 1 more comment
I have recently added elasticsearch as search engine for a project, it's an ecommerce structure model, and i use it to load categories, manufacturers etc.
The queries typically run very fast around 200ms which is pretty good considering the number products i have as on some projects i have more than 1 milion products.
However in some cases, like on a simple category page where i have around 550k products in that category page, the query takes around 500ms, i am wondering if i can optimize it to be faster.
Please not that i have aggregations and more filters added in the query depending on the options the customer selects, but for optimizing purposes i have removed them as i have the same loading speed with or without them.
This is the query which in that particular case takes around 500-600 ms
Array
(
[size] => 48
[from] => 0
[sort] => Array
(
[date_upd] => Array
(
[order] => desc
)
)
[query] => Array
(
[bool] => Array
(
[filter] => Array
(
[0] => Array
(
[term] => Array
(
[id_product_categories] => 38231
)
)
)
)
)
)
The elasticsearch index structure is as follows:
$data = array(
'settings' =>
array(
'number_of_shards' => 1,
'number_of_replicas' => 0,
'analysis' => $analysis,
'index' => array(
'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),
'sort.order' => array('desc','desc','desc','desc')
)
),
'mappings' => array(
'product' => array(
//'type' => 'product',
'_all' => array( 'enabled' => false),
'properties' => array
(
'id_product' => array(
'type' => 'integer'),
'id_image' =>array(
'type' => 'integer',
'null_value' => 0
),
'id_supplier' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_manufacturer' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_color' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'rating' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'id_default_category' => array(
'type' => 'integer',
'null_value' => 0
),
'popularity' => array(
'type' => 'integer',
'null_value' => 0
),
'reduction_percent' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'is_reduced' => array(
'type' => 'boolean'
),
'reference' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'image_cover' => array(
'type' => 'keyword',
'index' => false,
),
'image_title' => array(
'type' => 'keyword',
'index' => false,
),
'product_link_title' => array(
'type' => 'keyword',
'index' => false,
),
'price' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'old_price' => array(
'type' => 'float',
'null_value' => 0
),
'id_product_categories' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'date_add' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss',
'index' => true
),
'date_upd' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss'
),
'product_name' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_heading' => array(
'type' => 'keyword',
"index" => false
),
/*
'product_description' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
*/
'product_color' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_categories' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_manufacturer' => array(
'type' => 'text',
),
'product_supplier' => array(
'type' => 'text'
),
'product_link' => array(
'type' => 'keyword',
'index' => false
)
)
)
)
);
I have recently added elasticsearch as search engine for a project, it's an ecommerce structure model, and i use it to load categories, manufacturers etc.
The queries typically run very fast around 200ms which is pretty good considering the number products i have as on some projects i have more than 1 milion products.
However in some cases, like on a simple category page where i have around 550k products in that category page, the query takes around 500ms, i am wondering if i can optimize it to be faster.
Please not that i have aggregations and more filters added in the query depending on the options the customer selects, but for optimizing purposes i have removed them as i have the same loading speed with or without them.
This is the query which in that particular case takes around 500-600 ms
Array
(
[size] => 48
[from] => 0
[sort] => Array
(
[date_upd] => Array
(
[order] => desc
)
)
[query] => Array
(
[bool] => Array
(
[filter] => Array
(
[0] => Array
(
[term] => Array
(
[id_product_categories] => 38231
)
)
)
)
)
)
The elasticsearch index structure is as follows:
$data = array(
'settings' =>
array(
'number_of_shards' => 1,
'number_of_replicas' => 0,
'analysis' => $analysis,
'index' => array(
'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),
'sort.order' => array('desc','desc','desc','desc')
)
),
'mappings' => array(
'product' => array(
//'type' => 'product',
'_all' => array( 'enabled' => false),
'properties' => array
(
'id_product' => array(
'type' => 'integer'),
'id_image' =>array(
'type' => 'integer',
'null_value' => 0
),
'id_supplier' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_manufacturer' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'id_color' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'rating' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'id_default_category' => array(
'type' => 'integer',
'null_value' => 0
),
'popularity' => array(
'type' => 'integer',
'null_value' => 0
),
'reduction_percent' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'is_reduced' => array(
'type' => 'boolean'
),
'reference' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
),
'image_cover' => array(
'type' => 'keyword',
'index' => false,
),
'image_title' => array(
'type' => 'keyword',
'index' => false,
),
'product_link_title' => array(
'type' => 'keyword',
'index' => false,
),
'price' => array(
'type' => 'integer',
'null_value' => 0,
'index' => true
),
'old_price' => array(
'type' => 'float',
'null_value' => 0
),
'id_product_categories' => array(
'type' => 'keyword',
'null_value' => 0,
'index' => true,
'eager_global_ordinals' => true
),
'date_add' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss',
'index' => true
),
'date_upd' => array(
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss'
),
'product_name' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_heading' => array(
'type' => 'keyword',
"index" => false
),
/*
'product_description' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
*/
'product_color' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_categories' => array(
'type' => 'text',
"analyzer" => $lang_iso_code .'_analyzer'
),
'product_manufacturer' => array(
'type' => 'text',
),
'product_supplier' => array(
'type' => 'text'
),
'product_link' => array(
'type' => 'keyword',
'index' => false
)
)
)
)
);
asked Mar 27 at 12:56
Pepelea Razvan IonutPepelea Razvan Ionut
307 bronze badges
307 bronze badges
Are you sure that is a query execution time, but not data fetching time? If your query returns 550K items that could just take long time to pass all data. Try to limit results to confirm if that is the case
– Alex
Mar 27 at 13:09
@Alex I am certain that is not the fetching time, it only returns 48 elements, i have size => 48 at the beginning of the query, see the example above. There are 550k total products in the query (total hits)
– Pepelea Razvan Ionut
Mar 27 at 13:40
Anyone can help with this?
– Pepelea Razvan Ionut
Mar 28 at 18:45
I don't have Elastic sever to test at the moment. But just a guess, extend yoursettings=>'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),withid_product_categories
– Alex
Mar 28 at 19:05
If this is your actual query (I don't see the aggregation part). Atermquery should be really fast -- but you're wrapping it inside afilterso ES will cache it. Normally having a cache is really good, but if it's trying to fit in your most expensive query ... maybe not. You can check if it's still 500ms if you just runquery: term: [id_product_categories] : value : "38231"
– Tessmore
Mar 28 at 23:45
|
show 1 more comment
Are you sure that is a query execution time, but not data fetching time? If your query returns 550K items that could just take long time to pass all data. Try to limit results to confirm if that is the case
– Alex
Mar 27 at 13:09
@Alex I am certain that is not the fetching time, it only returns 48 elements, i have size => 48 at the beginning of the query, see the example above. There are 550k total products in the query (total hits)
– Pepelea Razvan Ionut
Mar 27 at 13:40
Anyone can help with this?
– Pepelea Razvan Ionut
Mar 28 at 18:45
I don't have Elastic sever to test at the moment. But just a guess, extend yoursettings=>'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),withid_product_categories
– Alex
Mar 28 at 19:05
If this is your actual query (I don't see the aggregation part). Atermquery should be really fast -- but you're wrapping it inside afilterso ES will cache it. Normally having a cache is really good, but if it's trying to fit in your most expensive query ... maybe not. You can check if it's still 500ms if you just runquery: term: [id_product_categories] : value : "38231"
– Tessmore
Mar 28 at 23:45
Are you sure that is a query execution time, but not data fetching time? If your query returns 550K items that could just take long time to pass all data. Try to limit results to confirm if that is the case
– Alex
Mar 27 at 13:09
Are you sure that is a query execution time, but not data fetching time? If your query returns 550K items that could just take long time to pass all data. Try to limit results to confirm if that is the case
– Alex
Mar 27 at 13:09
@Alex I am certain that is not the fetching time, it only returns 48 elements, i have size => 48 at the beginning of the query, see the example above. There are 550k total products in the query (total hits)
– Pepelea Razvan Ionut
Mar 27 at 13:40
@Alex I am certain that is not the fetching time, it only returns 48 elements, i have size => 48 at the beginning of the query, see the example above. There are 550k total products in the query (total hits)
– Pepelea Razvan Ionut
Mar 27 at 13:40
Anyone can help with this?
– Pepelea Razvan Ionut
Mar 28 at 18:45
Anyone can help with this?
– Pepelea Razvan Ionut
Mar 28 at 18:45
I don't have Elastic sever to test at the moment. But just a guess, extend your
settings => 'sort.field' => array('date_add','date_upd', 'reduction_percent','price'), with id_product_categories– Alex
Mar 28 at 19:05
I don't have Elastic sever to test at the moment. But just a guess, extend your
settings => 'sort.field' => array('date_add','date_upd', 'reduction_percent','price'), with id_product_categories– Alex
Mar 28 at 19:05
If this is your actual query (I don't see the aggregation part). A
term query should be really fast -- but you're wrapping it inside a filter so ES will cache it. Normally having a cache is really good, but if it's trying to fit in your most expensive query ... maybe not. You can check if it's still 500ms if you just run query: term: [id_product_categories] : value : "38231" – Tessmore
Mar 28 at 23:45
If this is your actual query (I don't see the aggregation part). A
term query should be really fast -- but you're wrapping it inside a filter so ES will cache it. Normally having a cache is really good, but if it's trying to fit in your most expensive query ... maybe not. You can check if it's still 500ms if you just run query: term: [id_product_categories] : value : "38231" – Tessmore
Mar 28 at 23:45
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377755%2foptimize-elastic-search-query%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377755%2foptimize-elastic-search-query%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you sure that is a query execution time, but not data fetching time? If your query returns 550K items that could just take long time to pass all data. Try to limit results to confirm if that is the case
– Alex
Mar 27 at 13:09
@Alex I am certain that is not the fetching time, it only returns 48 elements, i have size => 48 at the beginning of the query, see the example above. There are 550k total products in the query (total hits)
– Pepelea Razvan Ionut
Mar 27 at 13:40
Anyone can help with this?
– Pepelea Razvan Ionut
Mar 28 at 18:45
I don't have Elastic sever to test at the moment. But just a guess, extend your
settings=>'sort.field' => array('date_add','date_upd', 'reduction_percent','price'),withid_product_categories– Alex
Mar 28 at 19:05
If this is your actual query (I don't see the aggregation part). A
termquery should be really fast -- but you're wrapping it inside afilterso ES will cache it. Normally having a cache is really good, but if it's trying to fit in your most expensive query ... maybe not. You can check if it's still 500ms if you just runquery: term: [id_product_categories] : value : "38231"– Tessmore
Mar 28 at 23:45