Bidzina Goginashvili

Bidzina Goginashvili

  • NA
  • 206
  • 26.5k

ElasticSearch pls Helppppp!!!!

Aug 1 2019 5:40 PM
I have a little problem with elastic search...
I have products table.which looks something like this
ID NAME MODELNAME IsParentModel
1 IPhone 7 16 gb IPhone 7 1
2 IPhone 7 32 gb IPhone 7 0
3 IPhone 7 64 gb IPhone 7 0
4 IPhone X 16 gb IPhone X 1
5 IPhone X 32 gb IPhone X 0
6 IPhone X 64 gb IPhone X 0
what i am trying to do is to get ParentProducts and then get all child products with same modelname, but problem is that i can't get more than (declared size) products.I Was trying to get Parent Modeled Products with first query and than get child queries but it is not returning all the child modeled products because by defauld it has size 10 and i don't know what to do.
I am developing elastic search on .net.This is what it looks like...
 
This query returns parentproducts...
 
var response = searchDescriptor.Size(50)
.Index("products")
.Query(q => q
.Terms(c => c
.Field("categories.id")
.Terms(categoryIds)))
.Query(z => z
.Bool(b => b
.Should(
sh => sh
.Term(tt => tt.IsParent, true))));
Get ReturnedProducts ModelNames
var sameModeledIds = _client.Search(searchDescriptor)
.Hits.Select(x => x.Source.ModelName).ToList();
And than i have Method to get all the children samemodelnamedProducts
var modelNamedProductIds = FilteredModelNames(sameModeledIds);
For returning childrens Method Looks Like this...
private int FilteredModelNames(IList modelIds)
{
var ressp = searchDescriptor
.Size(I dont need size i need to select all mathed data :((()
.Index("onoff-products-tests-main")
.Query(q =>
q.Terms(c =>
c.Field(x => x.ModelName.Suffix("keyword")).Terms(modelIds)))
.Query(z =>
z.Bool(b =>
b.Should(sh => sh.Term(tt => tt.IsParent, false))));
var resp = _client.Search(searchDescriptor)
.Hits.Select(x => int.Parse(x.Id)).ToArray();
return resp; }