Programmatically republishing a post excludes it from the Examine search results
We are stumped on this issue and would appreciate any ideas on why this is happening:
We needed our Examine search results to be weighted by date, so we added a new custom field for adding a boost number, added that field to the search index, and then set up a script to insert numbers based on a set of date ranges (a month old, 3 months old, etc). This approach itself is working, and returning the results in the order we were looking for.
The issue occurs when we programmatically save and publish the articles after adding or changing the custom boost number. The article will be published in the system -- it will say it is published in the backoffice, and will appear on the site; however, it will now be excluded from the search results. To include it in the search results again, we have to manually click "Save and Publish" in the backoffice.
Any ideas on why this is happening? We've tried rebuilding the index, with no luck.
I tried the SaveAndPublish method with raiseEvents set to true and we still get the same result - we need to click "Save and Publish" in the back office to have the content included in the Examine searches.
Fyi - we are not creating new content in the code but editing a custom property of an existing document and saving.
The Console.WriteLine shows attemptResult.Success is "true" and the updated value of "publicationDateSearchWeighting" is shown in the back office but the content is not listed in searches. If we click "Save and Publish" on the content in the back office it immediately shows up in the searches.
Programmatically republishing a post excludes it from the Examine search results
We are stumped on this issue and would appreciate any ideas on why this is happening:
We needed our Examine search results to be weighted by date, so we added a new custom field for adding a boost number, added that field to the search index, and then set up a script to insert numbers based on a set of date ranges (a month old, 3 months old, etc). This approach itself is working, and returning the results in the order we were looking for.
The issue occurs when we programmatically save and publish the articles after adding or changing the custom boost number. The article will be published in the system -- it will say it is published in the backoffice, and will appear on the site; however, it will now be excluded from the search results. To include it in the search results again, we have to manually click "Save and Publish" in the backoffice.
Any ideas on why this is happening? We've tried rebuilding the index, with no luck.
thank you
I think you need to go under the developer section and rebuild the indexes of the Searcher.
Are you doing this via the ContentService?
Have you got the RaiseEvents flag set to false on the SaveAndPublish event - I would think this needs to be true?
https://our.umbraco.com/documentation/reference/events/contentservice-events
Steve
Steve - thanks for the response. I am working with Shawn (OP) on this issue.
We are actually using the new SaveAndPublishWithStatus method.
contentService.SaveAndPublishWithStatus(descendant,0,true);
I tried the SaveAndPublish method with raiseEvents set to true and we still get the same result - we need to click "Save and Publish" in the back office to have the content included in the Examine searches.
Fyi - we are not creating new content in the code but editing a custom property of an existing document and saving.
Hi Shawn, James,
Can we see the code you have ?
Dave
Hi Dave, here is the code that is updating the property then saving and publishing the content.
The Console.WriteLine shows attemptResult.Success is "true" and the updated value of "publicationDateSearchWeighting" is shown in the back office but the content is not listed in searches. If we click "Save and Publish" on the content in the back office it immediately shows up in the searches.
James,
Any thing in the logs? There may be an error in your document writing event where you set the boost.
What you are looking to do here is date based decay something we have done before but they way we did it was with nightly reindex job.
The code for the boost calculation looks like:
Regards
Ismail
Hmmm
I wonder if the content nodes is not being marked as dirty / changed because you're changing a custom property.
Try adding a dummy, native field (e.g. a text field) and set this to a random string. Does it work then?
Steve
is working on a reply...