skybrud / skybrud.umbraco.search Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Example
Works:
VkNewsListOptions options = new VkNewsListOptions(Current.Logger)
{
Limit = limit,
Offset = offset,
Text = text,
Location = locationUdi,
Subject = subjectUdi
};
Fails:
VkNewsListOptions options = new VkNewsListOptions(Current.Logger)
{
Limit = limit,
Offset = offset,
Text = text,
Location = locationUdi,
Subject = subjectUdi,
IsDebug = true
};
public VkNewsListOptions()
{
ContentTypes = new ContentTypeList { Constants.VkConstants.DocumentTypes.NewsPage };
DisableHideFromSearch = false;
RootIds = new int[] { Constants.VkConstants.Pages.NewsList };
TextFields = new FieldList
{
new Field("nodeName_lci", 15),
new Field("title_lci", 10),
new Field("teaser_lci", 10)
};
}
Outputs:
hideFromSearch:0 (subjectArea_search:6e2715390e0a488791bfaf503d420c8e OR mntpLocations_search:33f2abd6a6b348978fb004362bef8edf OR mntpLocations_search:all OR mntpSubjects_search:all)
public VkNewsListOptions()
{
ContentTypes = new ContentTypeList { Constants.VkConstants.DocumentTypes.NewsPage };
DisableHideFromSearch = true;
RootIds = new int[] { Constants.VkConstants.Pages.NewsList };
TextFields = new FieldList
{
new Field("nodeName_lci", 15),
new Field("title_lci", 10),
new Field("teaser_lci", 10)
};
}
Outputs:
hideFromSearch:0 (subjectArea_search:6e2715390e0a488791bfaf503d420c8e OR mntpLocations_search:33f2abd6a6b348978fb004362bef8edf OR mntpLocations_search:all OR mntpSubjects_search:all)
Ran into an issue where for some reason it seems the datetime string saved is not a valid datetime. It throws a format exception but it has no info on what it is trying to parse. Would it be possible to add a try catch block here with some helpful logging?
The error gotten is this:
{
"Message": "An error has occurred.",
"ExceptionMessage": "String was not recognized as a valid DateTime.",
"ExceptionType": "System.FormatException",
"StackTrace": "at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)
at Skybrud.Umbraco.Search.SearchUtils.Sorting.GetSortValueByDateTime(ISearchResult result, String propertyAlias)"
}
It's this method: https://github.com/skybrud/Skybrud.Umbraco.Search/blob/v3/latest/src/Skybrud.Umbraco.Search/SearchUtils.Sorting.cs#L21-L30
Was thinking something along these lines could be super helpful in debugging it!
public static DateTime GetSortValueByDateTime(ISearchResult result, string propertyAlias) {
string dateString = result.GetValues(propertyAlias)?.FirstOrDefault();
if (!string.IsNullOrWhiteSpace(dateString)) {
try {
return DateTime.ParseExact(dateString, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
} catch(Exception e){
_logger.Error<SearchUtils>(ex, $"Error trying to convert to datetime for searchresult with id: {result.Id} and propertyAlias: {propertyAlias}")
}
}
string createdDate = result.GetValues("createDate")?.FirstOrDefault();
return createdDate == null ? DateTime.MinValue : new DateTime(long.Parse(createdDate));
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.