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

Find model properties returning null

Vote:
 

I have a model DeliveryLocation which is indexed using Find. If I look at a specific object in the index (using Find Explorer), I can see that that all properties on the model has correct values. One of the properties is called DelliveryCode: 

"DeliveryCode$$string": "3118155"

However, when I retrieve the object using a Find query, DeliveryCode and several other properties is null. 

Anyone seen this behavior before? Is it a bug?

#73208
Jul 10, 2013 13:25
Vote:
 

Hi Mari,

First off is DeliveryCode a string in your class? Why I am asking is that it is indexed as a string but it contains only numbers. Could it be that you have change the backing property from string to int? Then this might happen since it then can't bind it correctly when deserializing.

/Marcus

#73209
Jul 10, 2013 13:45
Vote:
 
#73210
Jul 10, 2013 13:45
Vote:
 

@Markus: The DeliveryCode property is of type string:

public string DeliveryCode { get; set; }

@Petter: I'm using a Find query to retrieve a list of DeliveryLocation objects - note that this is not CMS data. 

The query looks like this:

List<FindModels.DeliveryLocation> result = 
  SearchClient.Instance.Search<FindModels.DeliveryLocation>()
   .Filter(f => f.DeliveryZipCode.Match(zipCode))
   .Filter(f => f.CountryCode.MatchCaseInsensitive(countryCode))
   .Take(50).GetResult().ToList();

    

 

#73211
Edited, Jul 10, 2013 13:51
Vote:
 

Marcus, I will try changing model type from string to int.

#73212
Jul 10, 2013 13:56
Vote:
 

I don't think that is an issue. Was only if you had changed types and not reindexed. And the backing class didn't represent the object in the index correct. 

Are we 100% certaain that all models have DeliveryCode set? I have never seen this before so I am trying to rue out the obvious first.

#73213
Jul 10, 2013 14:02
Vote:
 

Yes, DeliveryCode is set. This happens on all results/queries: I have two properties that are of type string in the index:

"DeliveryZipCode$$string": "0767",
"DeliveryCode$$string": "3118155",

- they are always null when model is returned from a query.

 

#73214
Jul 10, 2013 14:22
Vote:
 

@Marcus: Could be be some kind of serialization issue?

#73334
Jul 16, 2013 7:58
Vote:
 

I must admit this is very strange. 

It could be a serilization issue but then you should see some errors in the log if you have it turned on. Altho I doubt it since it doesn't seem to be the hardest thing to serialize.

Is it possible for you to try and reindex and see if it still remains?

 

/Marcus

#73347
Jul 16, 2013 9:01
Vote:
 

Reindexing have no effect.

I've added the data to a test find service. If you want, I can email you the service address and model class - then you can test queries yourself. (I'll need you email address).

#73350
Jul 16, 2013 9:23
Vote:
 

magr [at] ep.se 

 

/Marcus

#73351
Jul 16, 2013 9:35
Vote:
 

Aparently this happens when my model class (the object I'm indexing) does not have a default empy contructor.

#73354
Jul 16, 2013 10:48
* 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.