I'd like to add some custom facets to the Alfresco (version 5.0.a) search page. I've created an extension which allows to override already created facets:
<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js">
<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-footer.lib.js">
var facet = widgetUtils.findObject(model.jsonModel, "id", "FCTSRCH_FACET_DESCRIPTION");
facet.config.label = "Document type";
facet.config.facetQName = "{http://www.someComp.com/model/comp/1.0}personGroup";
But it is not the right way I think.
The problem is that I cannot override the parent widgets, since they don't have ids (faceted-search.get.js).
How do I manage to add a custom facet to the model?
Another question is regarding parameter of the facet with name facetQName. In the same file (faceted-search.get.js) I met some strange syntax which I don't understand.
Some examples:
facetQName: "{http://www.alfresco.org/model/content/1.0}creator.__.u",
facetQName: "{http://www.alfresco.org/model/content/1.0}modifier.__.u",
facetQName: "{http://www.alfresco.org/model/content/1.0}description.__",
What do these .__.u and .__ suffixxes mean?
Well I finally solve the problem.
Just for clarification: I had a requirement to use 5.0.a version in which there is no Search Manager page.
The solution which I used is a bit dirty, but it worked. I just overwrite the faceted-search.get.js and changed the facets array by adding my custom metadata:
// Compose the individual facets
var facets = [
...
{
id: "FCTSRCH_FACET_DOCUMENT_TYPE",
name: "alfresco/search/FacetFilters",
config: {
label: "Document Type",
facetQName: "{http://www.mycomp.com/model/efiles/1.0}typeName.__.u",
sortBy: "ALPHABETICALLY",
hitThreshold: 1,
minFilterValueLength: 5,
maxFilters: 10,
useHash: false
}
...
If you are interested in details you can check this post: http://streetturtle.github.io/2015/01/20/faceted-search-alf-5-0-a/
Related
i am able to create a new field in a sharepoint list using the "createfieldasxml" method of "fields" endpoint.
There is a way to add this field to all content type, and not just to the default content type?
The other way i thought is to add manually every field i need to all the content type, but it's not the best solution. I did not find in the documentation that parameter, but it is present in the csom approach.
Thanks
I answered you question here: https://learn.microsoft.com/en-us/answers/questions/541651/sharepoint-rest-api-create-field-and-add-to-all-co.html
You could set the Options property to 4(AddToAllContentTypes) in the
body using createfieldasxml method like the below:
{
"parameters": {
"__metadata": {
"type": "SP.XmlSchemaFieldCreationInformation"
},
"SchemaXml": "<Field Type='Text' DisplayName='test' Name='test'></Field>",
"Options":4
}
}
The AddFieldOptions value can be found here:
https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee542202(v=office.15)
I'm using Kentico 9 and I'd like to be able to use different CK Editor style sets on different pages. I have added a style set to the styles.js file as follows.
CKEDITOR.stylesSet.add("mystyles", [{ name: "testone", element: "p" }]);
Then in the page I've added some JS as per the CK Editor web site.
if (CKEDITOR.currentInstance) {
CKEDITOR.currentInstance.config.stylesSet = "mystyles";
}
When I load the page containing the CK Editor, the style drop down contains the default style set, not the custom one I defined.
Does anyone know how to achieve this?
If I remember it right you need to define your new toolbarset in config.js (CMSAdminControls/CKEditor/config.js) dropdown.
Something like:
config.toolbar_Basic = [
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink']
];
The other thing - you need to add new option to this dropdown in Webparts application > EditableText webpart> Properties > HTMLAreaToolbar > DataSource
Here's the documentation you need to read.
The dropdown styles are defined in CMS\CMSAdminControls\CKeditor\styles.js, such as:
{ name: 'Italic Title', element: 'h2', styles: { 'font-style': 'italic' } },
You define the name of the style (the name appears in the dropdown), and then the element and style(s) that should be applied.
After editing the file, make sure you clear your browser cache.
As most Kentico admin interface pages are nested and iframe'd, the caching is pretty agressive, and your styles might not appear until cache is cleared.
Well, it's just javascript after all, so you can simply check the url in some if statement or in some switch-case and then apply styles you need. Do you need some code example? You should be able to find many of them on the internet :)
Here is how I solved my issue. I added the following to styles.js:
CKEDITOR.stylesSet.add("my-styles", [
{ name: "Paragraph", element: "p" },
{ name: "Heading 1", element: "h1" }
]);
Then, in the master page for the area of my site that needs to use the "my-styles" style set, I added:
<script>window.ckstyleset = "my-styles"</script>
Finally, in config.js I added:
var styleset = window.ckstyleset ? window.ckstyleset : "default";
config.stylesSet = styleset;
Using this approach I was able to customise the styles listed in the drop down depending on what master page was is use.
We have a custom action that follows some custom workflow logic behind the scenes and want to add a layout to the data captured to the settings. I was able to add a checkbox to enable the layout (its an optional thing) associated with the custom action but I cant seem to find how to add a layout editor to our form?
var f = shapeFactory.Form(
Id: "ActionForm",
_Outcomes: shapeFactory.TextBox(Id: "action-text-box", Name: "Action", Title: T("Action")),
_HasLayout: shapeFactory.CheckBox(Id: "HasLayout", Name: "HasLayout", Title: T("Uses Layout"), Value: "true"),
//_Layout: shapeFactory.Parts_Layout_Edit(Id: "Layout", Name: "Layout", Title: T("Layout"))
);
This is where I am at at the moment (the last line is commented because the part name is incorrect), but I feel I am missing some core concept for adding the layout editor... Any help would be appreciated!
I figured this out after much experimentation.
Add to the form description
_Form: shapeFactory.EditorTemplate(Id: "Form", Name: "Form", Title: T("From"), TemplateName: "Parts.Layout", Prefix: "LayoutPart",
Model: new LayoutPartViewModel {
LayoutEditor = layoutEditorFactory.Create("", Guid.NewGuid().ToString())
})
and then you need to add a script to the form page in order to reload the layout editor with the bound data.
$(document).ready(function(){
var layoutEditorData = JSON.parse($("[name$='.LayoutEditor.Data']").val());
window.layoutEditor = new LayoutEditor.Editor(window.layoutEditor.config, layoutEditorData);
});
I am new to ES and trying to search using java apis. I am unable to figure out how I can provide filed specific boosting using the java apis.
Here is the example:
My index document looks like:
_source": {
"th_id": 1,
"th_name": "test name",
"th_description": "test desc",
"th_image": "test-img",
"th_slug": "Make-Me-Smart",
"th_show_title": "Coast Tech Podcast",
"th_sh_category": "Alternative Health
}
When i search for keywords I want to boost the results higher if they found in the "th_name" compared to they're found in some other fields.
Currently I am using below code to do search:
QueryBuilder qb1 = QueryBuilders.multiMatchQuery(keyword, "th_name", "th_description", "th_show_title", "th_sh_category");
SearchResponse response = client.prepareSearch("talk").setTypes("themes")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setQuery(qb1)
.setFrom(start).setSize(maxRows)
.setExplain(true).execute().actionGet();
Is there anything I can do at query time to boost the document if the keyword is found in "th_name" field compared to found in other fields?
The accepted answer did not work me. ES version I am using is 6.2.4.
QueryBuilders.multiMatchQuery(keyword)
.field("th_name" ,2.0f)
.field("th_description")
.field("th_show_title")
.field("content")
Hope it helps someone else.
Edit: This has changed and does no longer work in ES 6.x and upwards.
You should also be able to boost a field directly in the Multi-match query:
"The multi_match query supports field boosting via ^ notation in the fields json field.
{
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
}
In the above example hits in the subject field are 2 times more important than in the message field."
In the java-api, just use the MultiMatchQueryBuilder:
MultiMatchQueryBuilder builder =
new MultiMatchQueryBuilder( keyword, "th_name^2", "th_description", "th_show_title", "th_sh_category" );
Disclaimer: Not tested
You can use "BoostingQuery"
http://www.elasticsearch.org/guide/reference/query-dsl/boosting-query.html
javadoc : https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/BoostingQueryBuilder.java
I am having trouble with a MOSS FulltextSqlQuery when attempting to filter People results on the Skills Managed Property using the CONTAINS predicate. Let me demonstrate:
A query with no filters returns the expected result:
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
Result
Total Rows: 1
ACCOUNTNAME: MYDOMAIN\Bob
SKILLS: Numchucks | ASP.Net | Application Architecture
But when I append a CONTAINS predicate, I no longer get the expected result:
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks'))
Result
Total Rows: 0
I do realize I can accomplish this using the SOME ARRAY predicate, but I would like to know why this is not working with the CONTAINS predicate for the Skills property. I have been successful using the CONTAINS predicate with a custom crawled property that is indicated as 'Multi-valued'. The Skills property (though it seems to be multi-valued) is not indicated as such on the Crawled Properties page in the SSP admin site:
http:///ssp/admin/_layouts/schema.aspx?ConsoleView=crawledPropertiesView&category=People
Anyone have any ideas?
So with the help of Mark Cameron (Microsoft SharePoint Developer Support), I figured out that certain managed properties have to be enabled for full text search using the ManagedProperty object model API by setting the FullTextQueriable property to true. Below is the method that solved this issue for me. It could be included in a Console app or as a Farm or Web Application scoped Feature Receiver.
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search.Administration;
private void EnsureFullTextQueriableManagedProperties(ServerContext serverContext)
{
var schema = new Schema(SearchContext.GetContext(serverContext));
var managedProperties = new[] { "SKILLS", "INTERESTS" };
foreach (ManagedProperty managedProperty in schema.AllManagedProperties)
{
if (!managedProperties.Contains(managedProperty.Name.ToUpper()))
continue;
if (managedProperty.FullTextQueriable)
continue;
try
{
managedProperty.FullTextQueriable = true;
managedProperty.Update();
Log.Info(m => m("Successfully set managed property {0} to be FullTextQueriable", managedProperty.Name));
}
catch (Exception e)
{
Log.Error(m => m("Error updating managed property {0}", managedProperty.Name), e);
}
}
}
SELECT AccountName, Skills
from scope()
where freetext(defaultproperties,'+Bob')
And ("scope" = 'People')
And (CONTAINS(Skills, 'Numchucks*'))
use the * in the end.
You also have a few more options to try:
The following list identifies
additional query elements that are
supported only with SQL search syntax
using the FullTextSqlQuery class:
FREETEXT()
CONTAINS()
LIKE
Source