Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Possible bug: XhtmlString breaks find

Vote:
 

Hello,

I was playing around with Epi Find and stumbled to a situation where Find doesn't return pages where I have XhtmlString properties. Here's a snippet from the page type.

    [ContentType(DisplayName = "StationPage", GUID = "7bc4dc60-fad0-43e4-8ed3-4f5b697aabf1", Description = "")]
    public class StationPage : PageData
    {
....
[CultureSpecific] [Display( Name = "Notification", GroupName = SystemTabNames.Content, Order = 1300)] public virtual XhtmlString Notification { get; set; } }

And search routine

public IEnumerable<string> GetAutocompleteList(string query)
        {
            var stationQuery = SearchClient.Instance.Search<StationPage>();

            foreach (var word in query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                stationQuery = stationQuery.Filter(f => f.Name.AnyWordBeginsWith(word));
            }

            return from station in stationQuery.GetContentResult()
                   select new
                       {
                           ...
                           Notification = station.Notification
                       };

         }

Now the search works fine with Station-pages which Notification property is empty. If I insert any text to it search doesn't return it or any other Station-page which might be the result of the search.

Is this a bug or am I doing something wrong?

 

-Marko

#65307
Jan 25, 2013 13:01
Vote:
 

Hi Marko,

Sounds very strange. What happens if you don't add the filters? Also, can you see the pages with values for Notification in the index (in the Explore view in Find's shell module)?

#65309
Jan 25, 2013 13:21
Vote:
 

Hi,

I left filters out and results are the same, nothing gets returned. I can see that pages are indexed in the Explorer view.

I have another search routine to get station names for autocomplete list. This works perfectly but this calls GetResult() instead of GetContentResult()

        public IEnumerable<string> GetAutocompleteList(string query)
        {
            var stationQuery = SearchClient.Instance.Search<StationPage>();

            foreach (var word in query.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                stationQuery = stationQuery.Filter(f => f.Name.AnyWordBeginsWith(word));
            }

            return stationQuery
                .OrFilter(f => f.StationFolderName.AnyWordBeginsWith(query))
                .Select(f => f.Name)
                .StaticallyCacheFor(TimeSpan.FromHours(1))
                .GetResult();
        }

    

#65310
Jan 25, 2013 13:43
Vote:
 

Hmm, could you inspect the result prior to using the Select method? Ie while debugging or in some other way.

As the Select method in the code you posted is applied after getting the result from the search engine I have a hard time seeing how the value in Notification could change what the search engine returns.

#65311
Edited, Jan 25, 2013 13:49
Vote:
 

I'll try that but can't do that just now. I'll get back to this next week.

#65312
Jan 25, 2013 13:51
Vote:
 

Hello again,

Now this is weird. I changed that particular property to be string type so I could get some work done. This morning I decided I'll try to debug this and changed it back to XhtmlString and ... now it works! I can't reproduce the error anymore.

Btw I stumbled another weird problem which might be related to this or not. When I changed property type from string->XhtmlString page type builder (or whatever it is called in Epi7) "forgot" to generate code for it. I got MissingMethodException saying that there's no get_Notification() method after installing (or in fact, installations are done automatically by scripts) application to our CI server. I forced another installation without any changes and magically exception went away.

#65436
Jan 30, 2013 9:15
Vote:
 

Hi,

Given what you last wrote and seeing as you got the original exception after you had executed the search, in the Select after GetContentResult, my guess is that the problem actually has to do with something weird going on with the CMS/typed pages. I think what happend is your search executed and the search engine returned references to matching pages. Then GetContentResult tried to fetch the pages for you and you did a projection webserver side. Somewhere in the last step an exception was thrown due to the issues with method's not being generated and GetContentResult's error handling "swallowed" them making it seem like you didn't get any hits.

That's just a guess though, but I think it makes sense considering the new facts in the case :)

#65438
Jan 30, 2013 9:25
Vote:
 

I'm getting the same bug to with Xhtml properties

model.Results = SearchClient.Instance.Search<ProductBlock>().For(searchTerm).InField(x => x.MainNarrative.ToString()).GetContentResult();

    

returns no results but using filter does

model.Results = SearchClient.Instance.Search<ProductBlock>().Filter(x => x.MainNarrative.AnyWordBeginsWith(searchTerm)).GetContentResult();

    

Not sure if unified search would work better. Any tips anyone. Am I doing something I shouldn't?

 

#77114
Edited, Nov 08, 2013 18:16
Vote:
 

To be honest I'm close to raising this as a bug - we are a bit worried about it over here. Even if it is an intermittent problem its a serious concern for us. I'll leave this up for a bit before rasiing. It's possible I've just missed something obvious. But the search being broken with XHtml strings will stop the implementation in it's tracks

Cheers

#77145
Nov 11, 2013 17:26
Vote:
 

Try changing

 .InField(x => x.MainNarrative.ToString())

to 

.InField(x => x.MainNarrative)

 

#77148
Nov 11, 2013 19:00
Vote:
 

Thank you for that - that actually works. There is still a samll bug where 

.InFields(x => x.LongSummary.ToString(), x => x.MainNarrative.ToString())

doesn't work with XHtml fields but I can live with that. Thanks 

 

#77449
Nov 19, 2013 16:47
Vote:
 

Skip the ".ToString()" there as well when specifying the InFields.

 

/Henrik

#77450
Nov 19, 2013 16:55
Vote:
 

Actually - if i skip the ToString() with inFields it won't compile so I do think there is an issue. Unless I'm missing something

#77551
Nov 21, 2013 9: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.