I am trying to sort my search results by a custom Umbraco property I have created - let's call it sortDate.
Inside my IndexSet, in config/ExamineIndex.config I have this:
<IndexUserFields>
<add Name="sortDate" EnableSorting="true" Type="DateTime" />
...
In my Search user control, I am constructing a criteria and filter and using them to search like so:
var criteria =
ExamineManager.Instance.SearchProviderCollection["MySearcher"].CreateSearchCriteria(
UmbracoExamine.IndexTypes.Content);
var filter =
criteria.GroupedOr(new string[] { "sortDate", "someThing", "someThingElse", "bodyText" }, SearchTerm.ToLower()).Compile();
var MySearchResults =
ExamineManager.Instance.SearchProviderCollection["MySearcher"].Search(filter).Distinct();
I'm guessing I need to add something to specify how Lucene should sort this on my filter?
This is Umbraco 4.6.1 if that matters :)
OK, not sure how I missed this, but it looks like you can just do:
filter.OrderBy( new string[] { "sortDate" } );
Related
In v10 of Azure Search SDK, I was able to specify exactly which fields to search in an index by taking advantage of SearchParameters class. In v11, I see there is SearchOptions, but the SearchFields parameter is get only. In v10, SearchFields has a setter.
How do I choose which fields to search on in v11?
You can call .Add() on the SearchFields property:
var options = new SearchOptions();
options.SearchFields.Add("field1");
options.SearchFields.Add("field2");
Or you can use C#'s list initializer syntax:
var options = new SearchOptions() { SearchFields = { "field1", "field2" } };
Example adapted from this GitHub issue.
I want to override the item listing template file core/themes/classy/templates/dataset/item-list.html.twig for listing the fields field_slider_images as well as field_blog_tags respectively of their's multiple values of the field.
I have selected "Unordered List" in the view.
Please do check the attached image.
I have created following files :
item-list--field-blog-tags.html.twig
item-list--field-slider-images.html.twig
But, this is not rendered for the listing of the fields.
When I have created item-list.html.twig then only it will access.
However, both fields have different data to style and I am not able to get the current field name which is loading it's data in item-list.html.twig.
Had a brief look at this and it doesn't seem that 'item-list' to have suggestions, which is quite unfortunate.
In this situation there are two options:
Create your own suggestion which would accomplish exactly what you need.
You'll have to do something like this:
/
/*add new variable to theme with suggestion name*/
function hook_theme_registry_alter(&$theme_registry) {
$theme_registry['item_list']['variables']['suggestion'] = '';
}
//send a value to newly added variable to use it build the suggestion
function hook_ENTITY_TYPE_view(array &$build, $entity, $display, $view_mode) {
//add condition here if field exists or whatever, do the same for other field
$build['field_slider_images']['#suggestion'] = 'field_slider_images';
}
//use newly added variable to build suggestion
function hook_theme_suggestions_THEME_HOOK(array $variables) {//THEME_HOOK=item_list
$suggestions = array();
if(isset($variables['suggestion'])){
$suggestions[] = 'item_list__' . $variables['suggestion'];
}
return $suggestions;
}
Now you should be able to use item-list--field-slider-images.html.twig
Second option is to do what others in core did: use a new theme
function hook_ENTITY_TYPE_view(array &$build, $entity, $display, $view_mode) {
//add condition here if field exists or whatever, do the same for other field
$build['field_slider_images']['#theme'] = array(
'item_list',
'item_list__field_slider_images',
);
}
I've been checking ServiceStack's documentation, but I haven't found a way to do many to many relationships with ServiceStack.OrmLite, is it supported? Is there a workaround (without writing raw sql)?
I'd like to have something like this:
Article <- ArticleToTag -> Tag
Thanks!!
It's not implicitly handled automatically for you behind the scenes if that's what you mean? But as OrmLite is just a thin wrapper around ADO.NET interfaces anything is possible.
In OrmLite, by default every POCO maps 1:1 with a table. So if you wanted the table layout you would create it just as it looks in your database, e.g.
var article = new Article { ... };
var tag = new Tag { ... };
var articleTag = new ArticleTag { ArticleId = article.Id, TagId = tag.Id };
db.Insert(article, tag, articleTag);
Although you might want to take advantage of the built-in blobbing in OrmLite where any complex type just gets serialized and stored in a single text field. So you could do something like:
var article = { new Article { Tags = { "A","B","C" } };
Where Tags is just a List<string> and OrmLite will take care of transparently serializing it in the database field for you.
I am trying to develop a customized SharePoint 2010 web part for FAST search. I am using Microsoft.Office.Server.Search.Query.KeywordQuery something like this:
var FASTquery = new KeywordQuery(proxy)
{
ResultsProvider = SearchProvider.FASTSearch,
QueryText = queryText,
ResultTypes = ResultType.RelevantResults | ResultType.RefinementResults
};
FASTquery.SelectProperties.AddRange(
new string[] { "Title", /* ..., */ "HitHighlightedSummary" });
ResultTableCollection searchResults = FASTquery.Execute();
I go on to bind searchResults[ResultType.RelevantResults] to a Repeater control. I'm trying to get the "hit highlighted summary" to appear by calling FASTquery.HighlightStringValue(). The value I'm passing is the HitHighlightedSummary from searchResults. An example of what this looks like for a result when searching for "ear" is:
<ddd/>FALSE ); GetDlgItem(IDC_<c0>EAR</c0>_PAIN_STATIC)->EnableWindow<ddd/>FALSE ); GetDlgIte(IDC_<c0>EAR</c0>_PAIN_ABSENT_RADIO<ddd/>FALSE ); GetDlgItem(IDC_<c0>EAR</c0>_PAIN_MILD_RADIO<ddd/>
However, when called with a string like this, FASTquery.HighlightStringValue() is throwing a System.ServiceModel.FaultException with the message "Value does not fall within the expected range."
What is the correct way to convert this excerpt to HTML, or should I be calling HighlightStringValue() with some other value? The documentation is not particularly helpful.
I typically perform a manual conversion of the hit highlighted summary markup to HTML. You'll find a combination of two markers in the summary:
<c0> </c0> (Highlight)
<ddd/> (Ellipsis)
A manual transformation of the markup could be as simple as the following string replacement:
string hitHighilghtedSummary;
// ...
hitHighlightedSummary = hitHighlightedSummary.Replace("c0", "strong").Replace("<ddd/>", "…");
I'm looking for a way to get all records where deleted is set to true on a particular table. How might I accomplish this?
Note: Using auto-generated class by SubSonic. Not T-SQL.
The auto-generated SubSonic classes don't support querying logical deletes. But you can do this (version 2.1/2.2 syntax):
public partial class TableClassCollection
{
public TableClassCollection LoadAll(bool suppressLogicalDeletes)
{
SubSonic.SqlQuery q = new SubSonic.Select(TableClass.Schema)
.From(TableClass.Schema);
if (suppressLogicalDeletes)
{
q.Where(TableClass.DeletedColumn).IsEqualTo(false);
}
return q.ExecuteAsCollection<TableClassCollection>();
}
}
More examples at subsonicproject.com
I've never heard of SubSonic before, but a quick Google search turned up: Select Queries in SubSonic.
So, using that page as a guide, it sounds like you'd be able to write your query as:
FooCollection deletedFoos = // use the generated collection class
DB.Select().From("FooTable") // table name goes here
.Where("deleted").IsEqualTo(true) // might need 1, depends on database?
.ExecuteAsCollection<FooCollection>(); // should match the type above
not a lot of detail in your question, but assuming there's a column named "deleted," it would look something like this:
select * from tableName where deleted = true