After watch Sebastien Ros's excellent primer on customizing search in Orchard - see https://www.youtube.com/watch?v=7v5qSR4g7E0 - I have been playing around with creating my own custom search.
This code, excerpted from my SearchController.cs works fine for sorting by create date.
if (String.Equals(order, "created", StringComparison.OrdinalIgnoreCase)) {
searchBuilder = searchBuilder.SortByDateTime("created").Ascending();
}
But I need to sort by "title" not create date. Something like this that actually works.
if (String.Equals(order, "title", StringComparison.OrdinalIgnoreCase)) {
searchBuilder = searchBuilder.SortBy("title");
}
My URL string looks like this:
http://localhost:333333//Search/?q=&order=title
Any tips on sorting search in Orchard would be greatly appreciated.
Thanks!
Related
I'm attempting to exclude all Web Content Articles with tag "no-search" applied to them from appearing in search results. However, I'm having difficulty figuring out how to set up the Custom Filter widget for that.
Here's what I have:
Filter Field: tagNames (have also tried assetTagNames)
Filter Value: no-search
Filter Query Type: Exists (have tried everything in the list with no success)
Occur: must_not
The documentation isn't being terribly useful for this. I even tried other example filter parameters provided on this page and they didn't function as expected either. What parameters do I need to use to do this successfully?
Answering for myself, since I ended up reaching out to Liferay support for help with this, and so this is accessible to anyone searching for it in the future. Here's what they told me to use.
Filter Field: assetTagNames
Filter Value: no-search (or your own exclusion tag here)
Filter Query Type: Match
Occur: must_not
It seems that facets doesn't work properly with multi language properties.
I did a simple test in Alfresco 5.0.a and 5.0.b on clean installation:
Created a text document in site.
Put description in English.
Changed browser language to French.
Added French version of the description.
Searched for the file name.
Found only one document which was just created.
The problem is that in Description facet on the left panel I have two descriptions - one English and one French.
Both points to the same file, but logically there should be only one description (depends on the browser's language).
Did anybody faced this problem? It seems like a bug.
Hi I'm not sure if it's a bug, but technically it looks like it should be.
Multilingual fields contains multiple text definitions of the same field. Solr indexes the field and sees there are 2 values (even though for the same field) so he creates a facet out of them.
Sure it's possible in the UI to filter out, Alfresco probably will need to do it (raise a JIRA so they can take a look). But in case of technical faceting/filtering it works like it should.
I raised an issue ALF-21249
And also found a workaround, which is a bit dirty, but works well.
Let's say you have a property with name ccm:property which has type d:mltext and you want to have facet for this property in English and French.
Define an aspect with two d:text properties: ccm:propertyEn and ccm:propertyFr
Apply this aspect to the type.
When you set the ccm:property set also ccm:propertyEn and ccm:propertyFrproperties
Modify variable facets in faceted-search.get.js so that depends on the user's language one or another facet are shown:
if (locale.substring(0, 2)== "fr")
facetQName = "{http://www.ccm.com/model/ccm/1.0}propertyFr.__.u";
else
facetQName = "{http://www.ccm.com/model/ccm/1.0}propertyEn.__.u";
facets.unshift(
{
id: "FCTSRCH_FACET_DOCUMENT_TYPE",
name: "alfresco/search/FacetFilters",
config: {
label: msg.get("faceted-search.facet-menu.facet.docType"),
facetQName: facetQName,
sortBy: "ALPHABETICALLY",
hitThreshold: 1,
minFilterValueLength: 5,
maxFilters: 10,
useHash: false
}
});
Done! :)
I have HtmlBlock field and I want to add this field to Orchard CMS index.
Is there some stuff I have to implement to add field in index, like OnIndexing method for custom part indexing described here: https://orchard.codeplex.com/discussions/255183
To enable custom fields indexing you need to describe fields in FieldDriver.
protected override void Describe(DescribeMembersContext context)
{
context
.Member(null, typeof(string), T("HTML"), T("The HTML value of the field."))
.Enumerate<HtmlBlockField>(() => field => new[] { field.HTML });
}
Okay, so after I actually read your question instead of just writing a dumbass comment repeating random words you had written, fields in Orchard automagically get that "include in index" added to them. This is done in the Indexing module in Settings/EditorEvents.cs. It should then go ahead and index your field. Make sure you enable Indexing :)
I did just test it on my super quickly made field and it did appear to work. But I wouldn't say I'm 100% sure ^_^
I was playing around with custom Search Indexing Handlers for SDL Tridion 2011 (GA). I got something working, using the very helpful information provided by Arjen, however I am not sure if my execution is the best option.
The requirement is to be able to search for pages in the CMS by url (eg www.example.com/news/index.html). In order to do this I have the created a class using the ISearchIndexingHandler interface (code below). I am indexing the url in the ContentText field of the item, however I am not sure if this would normally contain something else for a page (I think a page only has metadata so this should be OK). The advantage of using this over a custom field is that I can simply type the url in the search box without having to use <url> IN <fieldname> or something like that.
So my question is, is there any reason not to use ContentText for Pages, and is there any advantage in using a custom field? Also bonus marks go to anyone with good ideas on how to handle BluePrinting (if I create a page in a parent publication, I want the local urls also to be indexed in the child publications), and the case where a Structure group path is altered (I guess I can somehow trigger a re-index of child page items from within my indexing handler).
The code:
using System;
using Tridion.ContentManager.Search;
using Tridion.ContentManager.Search.Indexing.Handling;
using Tridion.ContentManager.Search.Indexing.Service;
using Tridion.ContentManager.Search.Indexing;
using Tridion.ContentManager.Search.Fields;
namespace ExampleSearchIndexHandler
{
public class PageUrlHandler : ISearchIndexingHandler
{
public void Configure(SearchIndexingHandlerSettings settings)
{
}
public void ExtractIndexFields(IdentifiableObjectData subjectData, Item item, CoreServiceProxy serviceProxy)
{
PageData data = subjectData as PageData;
if (data != null)
{
PublishLocationInfo info = data.LocationInfo as PublishLocationInfo;
string url = GetUrlPrefix(data) + info.PublishLocationUrl;
item.ContentText = url;
}
}
private string GetUrlPrefix(PageData page)
{
//hardcoded for now, but will be read from publication metadata
return "www.example.com";
}
}
}
You can store the url in the ContextText Property. Thies field is used to index Template content data.
Tridion does not index shared item(s) of child publication.
Indexing is triggered on Item modification(create, update, delete, localize and unlocalize).
Or you can use reindexing tool to reindex ur item. but there is no way to index shared items in child publication.
I don't think you can include the URL prefix in neither your search query as the indexed item. Because shared items are not indexed, you will probably index the Page from the Website Structure layer, which is never published.
When a Structure Group is moved you would have to make an event handler that triggers re-indexing all child pages using a protected method of the TOM.NET API. This method is not part of the public API, so posting the code for that solution would probably declare me a persona non grata with R&D :)
Before you re-index anything you should store the original publish location url of the Structure Group in the TcmEventArgs.ContextVariables property, so you can verify whether or not a re-indexing action is necessary.
For a project I am working on, I am trying to do the following thing.
There's a Sharepoint 2010 environment, with a few Custom Lists created in Visual Studio. I am adding some fields to them using background code in the FeatureActivated function in the EventReceiver.
What I am doing there is adding a lookup field to the Sharepoint List, and setting the properties to allow it to lookup values from the other list I am adding to the Sharepoint Site.
However, I can't find a function to add it to one of the views. I've tried modifying the Schema Xml, but I can't seem to find a function to reinsert it to the List, and when using the Xml file from the View, I can't seem to make it work.
Is there an easy way to programatically add a field to a view? This would help me out, since there seems to be no way to do this correctly.
This can also be solved if one could explain my other question I have.
I would like to know how one could make Lookup fields in the Schema XML file. I have a Custom Content Type, and Custom Fields, and I am currently trying to look up the Naam field in the Intermediairs List. (This one is also created when deploying this solution). When searching Google, it seems I have to use either a name / the GUID of a List Instance here, but I don't know the GUID of the List Instance beforehand.
<Field ID="{7CC49D9D-F6F5-4A4A-851F-3152AAAAB158}" Type="Lookup"
List="Intermediairs" Name="IntermediairLookup" DisplayName="Intermediair"
StaticName="IntermediairLookup" Group="Onboarding" ShowField="Naam" />
You should know that this code seems to work:
SPWeb web = null;
SPSite site = null;
if (properties.Feature.Parent is SPWeb)
{
web = properties.Feature.Parent as SPWeb;
site = web.Site;
}
if (properties.Feature.Parent is SPSite)
{
site = properties.Feature.Parent as SPSite;
web = site.RootWeb;
}
web.AllowUnsafeUpdates = true;
SPList changeList = web.Lists.TryGetList("Onboarding");
SPList sourceList = web.Lists.TryGetList("Intermediairs");
if (changeList != null && sourceList != null)
{
changeList.Fields.Delete("IntermediairLookup");
var PrimaryColumnStr = changeList.Fields.AddLookup("Intermediair", sourceList.ID, true);
var PrimaryColumn = changeList.Fields.GetFieldByInternalName(PrimaryColumnStr) as SPFieldLookup;
PrimaryColumn.LookupField = sourceList.Fields["Naam"].InternalName;
PrimaryColumn.Update();
}
But yeah. I can't figure out how to do it in XML form. Anyone has any ideas? A solution to either of the questions would solve my core issue.
Greetings,
Mats
EDIT: Well, the question has now been answered, thanks again!
One thing though. I would really like to know at some point how to do something like this in XML / CAML. Does anyone know how to do that? Anyone who's still reading this thread?
Take a look at SPView.ViewFields
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spview.viewfields.aspx