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?
Related
Currently I'm working with Hyperledger chaincode,
I have a problem with the method "GetStateByPartialCompositeKey".
They index consists of 3 parts (key1~key2~key3).
If i try GetStateByPartialCompositeKey(index, key1) , it works perfectly.
But If I try to search for another key, like GetStateByPartialCompositeKey(index, key3), nothing is returned. Although the key is actually saved. How do I solve this problem?
Refer: https://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim#ChaincodeStub.GetStateByPartialCompositeKey
As mentioned in the description of the method, "This function returns an iterator which can be used to iterate over all composite keys whose prefix matches the given partial composite key."
This method needs to have the prefix i.e. the first half of the composite key to match. Even though the method name may state partial key, it only works with the prefix of the composite key and not any part of it.
I am trying this query and it is not working:
OrderFulfillment.where(shopper_id: shopper.id, fulfillment_status: [:fulfillment_requested_assignment, :fulfillment_assigned, :fulfillment_shopping])
I am not sure why but I am unable to get querying using enums to work
OrderFulfillment.where(shopper_id: shopper.id,
fulfillment_status: OrderFulfillment
.fulfillment_statuses
.values_at([:fulfillment_requested_assignment,
:fulfillment_assigned,
:fulfillment_shopping]))
Rails isn't smart enough to know that you are passing keys and not values, so when you were passing the statuses straight like that it was looking for the wrong values (it changed them to null because it didn't understand). The enums are physically stored as integers, so that's what you actually need to use in the query. Therefore, you can use the Rails-provided fulfillment_statuses method to grab a hash of the key/value pairs of the enum, and then the values_at method of the hash to get the values for the array of keys you pass in.
How to use the KV_INCR_KEY?
I found a useful feature in gwan api, but without any sample.
I want to add items to the KV store with this as primary key.
Also, how to get the value of this key?
The KV_INCR_KEY value is a flag intended to be passed to k_add().
You get the newly inserted key's value by checking the return value of k_add(). The documentation states:
kv_add(): add/update a value associated to a key
return: 0:out of memory, else:pointer on existing/inserted kv_item struct
This was derived from an idea discussed on the G-WAN forum. And, like for some other flags (timestamp or persistence, for example), it has not not been implemented yet (KV_NO_UPDATE is functional).
Since what follows the next version (focussed on new scripted languages) is a kind of zero-configuration mapReduce, the KV store will get more attention soon.
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
I'm trying to merge a form hash with another hash using Prototype (1.6.0.3)
This doesn't pass any parameters to the server
Name
but this does
Name
Any ideas on how to fix this? I don't get any javascript errors.
Looks like this is an issue with the old version of the Prototype docs:
That's a documentation issue. Expected
output (from Form.serialize) is a
vanilla JS object, not a hash https://groups.google.com/group/prototype-core/browse_thread/thread/d686de54683b206c?pli=1
UPDATE
You can achieve what you want like this:
Name
This makes use of Object.extend:
Object.extend(Form.serialize(true), {order: 'descend_by_created_by'})