November Happy Hour will be moved to Thursday December 5th.

Searching a list of complex objects

Vote:
 

Hi 

I have a list of daterange objects (2 properits - 'to' and 'from', both datetime). I want to write a find filter that will return results if any of the objects are within a date range. The use case may make it clearer - a product with special offers. Return the product if any of the underlying special offers are in the valid date date.

I'm trying to use Nested2Find which lokks brilliant but i'm struggling to get it to work. (https://github.com/x2find/Nested2Find). The error is 

nested: QueryParsingException[[brownt_nitbdev2] [nested] nested object under path [SpecialOffersDateRange] is not of nested type]; }]

But the question is

Does anyone know how to either resolve this issue (i am using NetedList and AddNestedConventions) or is there another approach I can use. 

My total fall back option is to break out the list to 10 (or more) date range properties on the page and index those and they can be queried in the normal way - which is a rubbish solution really but if it comes to it .....

Many Thanks for any all help

 

#87674
Jun 19, 2014 11:13
Vote:
 

Hi - does anyone have any ideas. It's still a problem. I appreciate that it looks complex but I'd appreciate any thoughts

#87784
Jun 23, 2014 15:04
Vote:
 

How does your definition of the object where you use nested look?

#87935
Jun 25, 2014 18:55
Vote:
 

I think I would index the offer and the offer object would be those two date properties together with a product id then query Find for any offer objects within a date range.

#87943
Jun 26, 2014 0:15
Vote:
 

The index information is below. The problem is that I can't write a query using the API to pull out a product depending on the list of special offers. So the question I'm asking of the index is

Give me all the products that have at least one special offer within a given date range

The index is

"SpecialOffersDateRange": [
    {
      "$type": "Cds.Nitb.Web.Business.Search.DateRange, Cds.Nitb.Web",
      "From$$date": "2014-05-02T23:00:00Z",
      "To$$date": "2014-05-11T23:00:00Z",
      "HasRange$$bool": true,
      "___types": [
        "Cds.Nitb.Web.Business.Search.DateRange",
        "System.Object"
      ]
    },
    {
      "$type": "Cds.Nitb.Web.Business.Search.DateRange, Cds.Nitb.Web",
      "From$$date": "2013-01-15T00:00:00Z",
      "To$$date": "2013-06-29T23:00:00Z",
      "HasRange$$bool": true,
      "___types": [
        "Cds.Nitb.Web.Business.Search.DateRange",
        "System.Object"
      ]
    },
    {
      "$type": "Cds.Nitb.Web.Business.Search.DateRange, Cds.Nitb.Web",
      "From$$date": "2013-01-15T00:00:00Z",
      "To$$date": "2013-06-29T23:00:00Z",
      "HasRange$$bool": true,
      "___types": [
        "Cds.Nitb.Web.Business.Search.DateRange",
        "System.Object"
      ]
    },
    {
      "$type": "Cds.Nitb.Web.Business.Search.DateRange, Cds.Nitb.Web",
      "From$$date": "2013-01-15T00:00:00Z",
      "To$$date": "2013-06-29T23:00:00Z",
      "HasRange$$bool": true,
      "___types": [
        "Cds.Nitb.Web.Business.Search.DateRange",
        "System.Object"
      ]
    }
  ],
#87975
Jun 26, 2014 16:39
Vote:
 

To make SpecialOffersDateRange property being "nested" list it should be named like this: SpecialOffersDateRange$$nested.

"$$nested" - used by episerver find ES instance to determine that property is "nested" list (dynamic mappings)

You should ensure that you apply NestedFieldNameConvention(Nested2Find), use NestedList for SpecialOffersDateRange property in .Net code and reindex your documents after that.

#88351
Edited, Jul 09, 2014 12:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.