How to add distinct values in a multivalue field in solr - search

I have a multivalue field called category(which is also a store field) in which i need to add only distinct values
<field name="category">value1</field>
<field name="category">value2</field>
If I do a update as follows
<add>
<doc>
<field name="id">E02</field>
<field name="category" update="add">value2</field>
</doc>
</add>
I get the value2 stored twice
<field name="category">value1</field>
<field name="category">value2</field>
<field name="category">value2</field>
I need to store/update only disctinct values in category fields which is a multivalue fields. How to do this solr?
Thanks in advance,
Jagadesh.

This functionality has been added for Solr 7.3.
You can use the add-distinct atomic update action, instead of add
See the Jira issue (SOLR-11267) and the documentation in the Reference Guide:
add-distinct
Adds the specified values to a multiValued field, only if
not already present. May be specified as a single value, or as a list.

One can "set" instead of "add", to recreate a stored field in partial document updates. So if it is the case where you have all the field values,just stick them in a Set and then repopulate the field. You have all the data to recreate it because of stored field requirement.

Related

Change application access user right in odoo 12

i want to change application access user right.
in Mark Demo, Administration is selection field and it has rights for Access Rights.
i want to change it to Settings.
in python file self.env.user.has_group('base.group_system') returns False.
it means in selection field it fielded with Blank or Access right.
how can i change it to Settings.
i found this group in base.
<record model="res.groups" id="group_system">
<field name="name">Settings</field>
<field name="implied_ids" eval="[(4, ref('group_erp_manager'))]"/>
<field name="users" eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"/>
</record>
When we change the value of Administration field and click on save button Odoo as usual calls write method, the first thing Odoo does, in this case, is calling _remove_reified_groups method to remove reified group fields (sel_groups_2_3 in your example) from values and compute the value of groups_id then add it to values to be written in the next step (when calling super).
_remove_reified_groups compute groups to add or remove from groups_id. if a reified group field is present in values and has a value it will be added to groups_id, each time a reified group field is present in values the method calls get_selection_groups(key) to compute the groups to remove, the method returns the groups ids present in the field name. for the administration field sel_groups_2_3 the method will return [2, 3].
To reproduce the same result when updating Administration group we need to remove the groups used in field name then add the selected group to groups_id (values['groups_id'] = [(3, 2), (3, 3), (4, 3)])
The XML code used to set Mark demo administration group to Settings group should be:
<record id="base.user_demo" model="res.users">
<field name="groups_id" eval="[(3,ref('base.group_erp_manager')),(3,ref('base.group_system')),(4,ref('base.group_system'))]"/>
</record>

Issue with retrieving CRM D365 Option set field Data using Azure Data Factory

I have connected to my D635 instance by creating a pipeline and Dataset in azure Data Factory and have given fetchXML as source to retrieve the data. But when I preview the data I can only see number values for Option set fields in my output data.
Could anyone clarify me if we can normalize Optionset field values in ADF and use it?
Thanks!
You can use a link-entity element in your FetchXML query. You just need to lookup the objecttypecode of your entity.
Once you have the value you can use the following to bring in the textual value of an OptionSet selection.
<link-entity name="stringmap" from="attributevalue" to="____" visible="false" link-type="outer" alias="____">
<filter type="and">
<condition attribute="objecttypecode" operator="eq" value="___"/>
</filter>
<attribute name="value"/>
</link-entity>
to should be the name of the OptionSet column on the host/root entity
alias whatever you want to call the column in the output. I used the same value as to
value This is the object type code for your host/root entity. It is an integer value.

How can I get the Advanced Database Crawler to index the item name

I'm trying to switch my Sitecore application's search from the "old" indexes (Sitecore.Data.Indexing) to the "new" indexes (Sitecore.Search).
I used to have an index that explicitly listed the fields that I wanted indexed. The Item's name was one of these:
<field target="name">#name</field>
The new indexes, along with the Advanced Database Crawler allow you to have include fields and exclude fields. I've set the index IncludeAllFields value to false, as there are more fields I want to leave out than I want to index. And I add the fields I want via includes:
<include hint="list:IncludeField">
<!-- Field 1 -->
<fieldId1>{396CA18D-0E46-437E-9237-C10FDB217666}</fieldId1>
<!-- Field 2 -->
<fieldId2>{396CA18D-0E46-437E-9237-C10FDB217666}</fieldId2>
<!-- Field 3 -->
<fieldId3>{CC45947E-A22C-44E3-9652-32E519DABC7F}</fieldId3>
</include>
The problem is I can't figure out how to add the item's name with these new indexes. As far as I know the item's name isn't in a field. I tried looking at a sample item's fields after calling item.Fields.ReadAll() and looking through them all, but I couldn't see the item's name.
Is the item's name in a field that I can add to the include list, or is there another approach?
Thanks

Is there any way of setting a value for datetime field in ListInstance

I am creating a feature that declares a custom list template and a list instance from this template. Also, ListInstance contains several rows with default data and in my content type there's a DateTime field with DateTimeFormat set to DateTime.
The part with DateTime field in ListInstance looks like follows:
<Row>
<Field Name="MyOtherField"></Field>
<Field Name="MyDateTimeField">2011-12-30T21:00:00.0000000Z</Field>
<Field Name="MyIntField">0</Field>
</Row>
When I am trying to activate a feature, if shows me the following error:
The element 'MyListInstance' of type 'ListInstance' for feature 'MyFeature' (id: GUID) threw an exception during activation: String was not recognized as a valid DateTime.
Was trying to use local datetime format (en-US) or ISO 8601 format - no luck so far.
So the question is - what datetime format to use when I need to define DateTime field value in ListInstance?
Try:
<Row>
<Field Name="MyOtherField"></Field>
<Field Name="MyDateTimeField">2011-12-30T21:00:00Z</Field>
<Field Name="MyIntField">0</Field>
</Row>
I have a Feature that has loaded a Date field using that format.

Update SharePoint file field that is of type choice muliple selection

I am using UpdateListItems method (Lists.asmx web service) to update fields of an uploaded document in one SharePoint document library. In my case, I have a document library called Schedules. In it, there's a field called 'Day of the Week' which is a Choice multiple selection, with the allowed values Monday to Sunday. Here's the query that I have found which should select Monday and Friday choices (and it doesn't work, obviously):
<Method ID='1' Cmd='Update'>
<Field Name='ID'>1</Field>
<Field Name='Day of the Week'>Monday#;Friday</Field>
</Method>
I have read somewhere that inserting the string "#;" between the choices should resolve this. The end result is that the field Day of the Week is updated with the string "Monday#;Friday" and when I want to edit the item, no selection is being made. On the other hand if I just use "Monday", it works. Now, how can I make it update the multiple selection? Thanks.
I believe that should be ;#
A quick check shows the way SharePoint stores multi-choice fields, try:
;#Monday;#Friday;#
With the delimiter on the beginning and the end.
And a note: You should also keep in mind that SharePoint stores choices as plain text (not references), so you can place any value there, as you've just witnessed.

Resources