What is wrong with this elastic search groovy script? - elasticsearch

I am trying to dynamically add a field using groovy script where if the field exists then just add a new element to the array,if not then create the field with the first value.
if(!ctx._source.containsKey(\"Activities\")) { ctx._source.Activities = [activity] }else{ctx._source.Activities += activity}
I am passing the activity param properly but this operation is returning a error:
"remote_transport_exception:
[Stonecutter][127.0.0.1:9300][indices:data/write/update[s]]"
Do you guys have any suggestion?

The map object of your Doc does not support the "+=" operator, u can checkout the right way to update the Doc in the official guide.

Related

Liferay 7 search not returning results - Custom entity

I'm trying to enable search for a custom entity, I've implemented the indexer and trying to execute search as below but the search doesn't return any document/results
SearchContext searchContext = SearchContextFactory.getInstance(request);
searchContext.setKeywords(keywords);
searchContext.setAttribute("paginationType", "more");
searchContext.setStart(0);
searchContext.setEnd(10);
Indexer indexer = IndexerRegistryUtil.getIndexer(Position.class);
Hits hits = indexer.search(searchContext);
System.out.println("Hit count: " + hits.getLength());
The indexer implementation seems to be working, as I can see the records indexed as expected using built-in elastic search console
localhost:9200/liferay-20116/_search
Any clue what can be the possible problem??
Just for additional info, my custom entity doesn't contain a field for 'groupId'
Look like for some reason you must have groupId in your entity in order for the search to work unless you are willing to dig and override the behavior
I added groupId to my entity (though I was not interested) and boom, it worked

How to correctly add constraints to the querybuilder node for CQ5 Reports

I'm working on creating a custom report report page in CQ5. I've got my reportbase and columnbase components set up correctly, by following the steps listed here. I am able to, for instance, pick up all the templates that are available, by setting the property nodeTypes to cq:Template
I want to add a constraint to it, say for example pick up templates whose jcr:title is foo. I created a node under querybuilder called propertyConstraints and added my constraints in the form of nodes below it, as describedhere. However, this does not work for me at all.
What is the correct way to add constraints to the querybuildernode? Has anyone tried this?
Also, once I get this working correctly, can I extend this example to return pages of a specific template?
Have you looked into the QueryBuilder API? Adobe's documentation discusses how to match 1 or more property values.
Create a node propertyConstraints under queryBuilder of type nt:unstructured
create another node under propertyConstraints with any name.
Add properties to this node :
name String jcr:title
value String foo

Add new attribute to existing hash

I am retrieving results using Mongoid, but I want to add a new attribute to each of the records returned in an instance variable using the key. How would I go about doing this?
In PHP I would do this by looping through the array and inserting it based on the key of the object. I am unable to figure out how this can be done in Ruby when I receive the message: Model ABC can't be converted into an Integer.
Update: I ended up adding a method in the model to achieve what I was trying to do.
I'll try to point you in the right direction.
If you have an array of records and what to loop through it, use Array#each: http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-each
You can write attributes easily: http://rdoc.info/github/mongoid/mongoid/Mongoid/Attributes#write_attribute-instance_method
Hope that helps

Ruby, Neography Gem: Finding nodes via Key/value Pair

I am using Neography. I created an index, and have a node with this property:
But this code returns nil:
#neo.find_node_index("lucene","id_str", "5426722")
What am I doing wrong?
The format is: #neo.get_node_index(index, key, value)
The name of your index happens to be the same name as your key (I am assuming since we can see the index name, but not the key that was used).
#neo.get_node_index("id_str","id_str", "5426722")
You can find some examples on how to do it in the neography GitHub repository.
Have you tried get_node_index instead. It looks like it should have the same functionality for the values you are supplying, since you aren't passing a query?

MS CRM QueryExpression ConditionExpression w/ CRMBoolean type

I'm using Microsoft's CRM software (4.0) and I'm trying to build a query expression. It works fine with querying only String values, but now I need to include a field that is of type CRMBoolean. I should also mention I'm querying custom entities.
So previously, in my query I would only search by a few fields, but they were all of type String. Now I need to add another ConditionExpression for a CRMBoolean. The type of custom entity I'm searching for has a field called "Condition" - which will either have a value of "true" or "false". In CRM the attribute is defined as a bit, but I didn't think that would make a difference.
Here is my code I'm trying to use to find records that have a condition of "true":
oCondition = New ConditionExpression()
oCondition.AttributeName = "myEntity_condition"
oCondition.Operator = ConditionOperator.Like
Dim bool As New CrmBoolean
bool.Value = True
oCondition.Values = New Object() {bool}
listConditions.Add(oCondition)
I don't get an error, but nothing really happens. The number of records that is returned never changes one way or another. Has anyone done this before?
Thanks in advance!
Instead of putting a CrmBoolean object in the oCondition.Values array, just put a regular true/false boolean. I would also concur with benjynito on changing it to ConditionOperator.Equals instead of Like.
I don't know how the like operator is suppose to behave on a boolean. I wonder if its being ignored. Try ConditionOperator.Equal.

Resources