Developer forum

Forum » Ecommerce - Standard features » Index Query - how to i set up my query to fetch products in groups that are childs or grandchilds etc. of a group

Index Query - how to i set up my query to fetch products in groups that are childs or grandchilds etc. of a group

Hans Ravnsfjall
Hans Ravnsfjall
Reply

I have set up a webshops where i want an index query to fetch all products in groups underneath a certain group

Example:

My structure of groups is GrandParent/Parent/Child1, GrandParent/Parent/Child2 etc.

and the products are placed in the Child groups, but in my query I want to fetch all products that are in child groups  based on the ID of the GrandParent

 

I have tried setting up somthing like something like "where ParentGroupIds contains Group13"  - but this doesn´t work

Anyone have experience with this?

 

/Hans


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Hans,

 

Your logic is accurate, but use MatchAny instead of a Contains. Make sure your parameter is of type String or String[]

 

If you happen to call your parameter GroupID, despite associating it in the Expression with "ParentGroupIds", you can even take the benefit of customized URLs :)

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi Nuno

Thanx, I have tried this - but it doesnt work. My parameter is string, and my ParentGroupIds field is a a string[] - its indexed, stored and analyzed - but still doesn´t work

 

Is it correct to assume the GroupID structure is eg Group13, Group14 etc. ?

 

/Hans

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Hans,

 

Everything seems to be ok then. Have you tried to see if the data is properly indexed by downloading the index files and inspecting them using (for example) Luke?

 

It also peeked my interessed that you said the field in indexed, stored and analyzed. You "assume" that because you are using the schema extender, you inspected the lucene files (like I mentioned above) or did you create that field manually? If the later, I usually just go with the Schema extender.

 

If everything checks out, might as well wait for somebody from DK to chime in, get into your website and help you out further.

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi Nuno

Thank you so mutch for your time.

I actually used both the schema extender, but also created a field manually - called HRAGroupId - and its the type string[]

Unfortunately, I don´t know how to check the index manually. Will see if I can figure that out.

Have attached the index here

/Hans

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply
This post has been marked as an answer

Hi Hans,

Do you have a site, where I can see this behavior? 

If not, then you need to provide us all the files in Files/System/Indexes/{Your Repository}/{Your Index}/{Your Instance}.

I have tested Nunos approach and it seems to work perfectly, so there is probably something wrong with the either the data in the index or the request data.

Best regards,

Steffen

Votes for this answer: 1
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Tried setting the whole thing up again, doing exactly the same - and now it works. Guess it´s just unstable :/

Thanx for the help

/Hans

 

You must be logged in to post in the forum