I'm using Neo4j, and I wonder if it is possible to create a lucene index with a unique field. (that is, every key/value pair can be associated with only one node)
For example, i want to achieve the following behavior:
someIndex.add(node1, "firstName", "Roy");
someIndex.add(node2, "firstName", "John");
// Here I expect to recieve an exception because the key/value pair (firstName, Roy) is already associated with node1
someIndex.add(node3, "firstName", "Roy");
Is it possible to achieve something like that?
Thanks!
On Java API level you can use UniqueFactory. For usage example, check out http://docs.neo4j.org/chunked/stable/transactions-unique-nodes.html.
In my code I'm using the BatchInserterIndex and add a map of key and values I need to be indexed..
The code is something like this:
BatchInserterIndex myIndex = indexProvider.nodeIndex("myIndex", MapUtil.stringMap("type", "exact"));
Map<String, Object> key_Value_IndexMap = new ConcurrentHashMap<String, Object>();
key_Value_IndexMap.put("ID", value);
myIndex.add(createdNodeId, key_Value_IndexMap);
Related
What I am trying to achieve is is a map that has a list of maps in which the first key is ID and value obviously is a map of which the key is Session and the value is an OBJECT.
var newSession = ConcurrentHashMap<String, ConcurrentHashMap<WebSocketSession, String>>()
What if I want to save multiple session maps with the same ID? Whenever I pass an ID I want to get a map from which I should be able to search a particular session?
Sorry for not being so clear, but I am stuck here for a while and am kinda newbie in Kotlin!
Thanks in advance!
How do I find all the records in Redis?
USER_EXCHANGE = table
USER_ID = User ID (primary key)
UID = relationship
The key is stored with the following structure
USER_EXCHANGE:USER_ID:4030:UID:63867a4c6948e9405f4dd73bd9eaf8782b7a6667063dbd85014bd02046f6cc2e
I am trying to find all the records of the user 4030...
using (var redisClient = new RedisClient ())
{
List<object> ALL_UID = redisClient.Get<List<object>>("USER_EXCHANGE:USER_ID:4030:UID:*");
}
What am I doing wrong? Thank you all for your help.
Hi as you're trying to fetch all keys matching a pattern you should use KEYS.
GET won't match patterns. by will retrieve complete full names.
Caution this is a debug function and not a production function.
doc: https://redis.io/commands/keys
Production simple solution, recommanded for you is :
store a list of your key in a LIST
USER_EXCHANGE:USER_ID:4030 => [ uid1, uid2, uid3 ....]
get list of uids for a specific user ID by getting the list.
This is a good practice in REDIS.
I'm no aficionado of databases and I'm new to level as I've only dealt with SQL. My question seems simple, while I can put and get key value pairs in level, how do I create a record with more attributes?
So like I have key="president" and value="Nixon", but how can I give that value attributes? ie:
"Nixon":[{"approvalRating": 10, "suitColor":"blue", "firstName":"Richard"}]
How can I interact with level to get results like this?
Thanks
The value can be object so instead of "Nixon" you could pass in
{
lastname: 'Nixon',
firstName:'Richard'
approvalRating: 10,
suitColor:'blue'
}
Hi I'm using CustomObject to bulid friends list but I'm facing below problem.
When I try to push a number to an array field it returns null value and the field is not updated but if I add it as a normal field (not pushing to array) it works fine.
Below is my code:
QBCustomObject friendsList = new QBCustomObject();
friendsList.setClassName("Friends");
HashMap<String, Object> fields = new HashMap<String, Object>();
fields.put("push[friendsId][]", "00001111");
friendsList.setFields(fields);
and logcat shows below api request:
https://api.quickblox.com/data/Friends.json?push[friendsId][]=00001111
but if I use below code it works but not append to array. It adds new record:
fields.put("friendsId", "00001111");
friendsList.setFields(fields);
Is there anything wrong with my way?
To update your record, your URL should look like
https://api.quickblox.com/data/Friends/id.json?push[friendsId][]= 00001111,
where id is a record id.
For example,
https://api.quickblox.com/data/Friends/111c0ec5535c12669c000721.json?push[friendsId][]= 00001111
Did my answer helped you ?
You can rewrite the whole record. Don't try to add an object separately into an array, update the whole record.
I wish to create an index with, lets say the following fields :
UID
title
owner
content
out of which, I don't want UID to be searchable. [ like meta data ]
I want the UID to behave like docID so that when I want to delete or update,
I'll use this.
Is this possible ? How to do this ?
You could mark is as non-searchable by adding it with Store.YES and Index.NO, but that wont allow you easy updating/removal by using it. You'll need to index the field to allow replacing it (using IndexWriter.UpdateDocument(Term, Document) where term = new Term("UID", "...")), so you need to use either Index.ANALYZED with a KeywordAnalyzer, or Index.NOT_ANALYZED. You can also use the FieldCache if you have a single-valued field, which a primary key usually is. However, this makes it searchable.
Summary:
Store.NO (It can be retrieved using the FieldCache or a TermsEnum)
Index.NOT_ANALYZED (The complete value will be indexed as a term, including any whitespaces)