I have an index that indexes all of my videos, but I am running AWS rekognition on this videos after they are uploaded and then appending another property "status" which determines if its porn or not.
How might I set a condition on the index that only tracks records with a condition of something like if a.property == 'good'
So, to set a video's label that is good like this:
MATCH (n:Videos)
WHERE // some condition
CALL apoc.create.addLabels( v, ["GoodVideo" ] ) // Add GoodVideo label
YIELD node
Then node will have two labels: Videos and GoodVideo
Then you can create index restricted to just GoodVideo
CALL db.index.fulltext.createNodeIndex(
"videoIndex", // name of index
["GoodVideo"], // List of Labels for Nodes to be indexed
// List of Properties to be indexed
["title", "description", "author", "tags", "mpd", "thumbnailUrl", "views", "publishDate"])
You can then match for either Video or GoodVideo (or both.). It might make sense to make Video and GoodVideo mutually exclusive or keep Video label for GoodVideo nodes. That's a design choice which depends on how you think you'll want to access your videos. (You can always change your mind later.)
E.g.
MATCH(v:Video)
MATCH(v:GoodVideo)
MATCH(v:Video:GoodVideo) // Video AND GoodVideo
MATCH(v:Video|GoodVideo) // Video OR GoodVideo
(I'm not sure why you used backslashes...). I would reconsider adding publishDate to the index.
honestly wasn't expecting a response this quick or nearly half as detailed. Im going to implement this tomorrow morning, appreciate the insight deeply.
Im thinking as I make that operation to change property status to "good" I will just update the label as youve shown here and then only index the "goodVideo" labels. Pretty simple solution but after typing so much code the brain functions a little slower. Thanks so much for the thought and the references.
The backslashes are only used in javascript code. I think for node.js it throws an error if you dont put backslashes.
I would reconsider adding publishData to the index.
Also why? Its the date of it being published, it does not change and helps when users query videos to show the date. Not bothered by the question, just genuinely curious.
I actually wasn't even thinking of that as I didnt really intend for users to be able to search by date. Im new to using indexes I thought you have to include the property to return that data when you run a search on it. So in this case Im literally just including date there because the search page videos should have dates beside them.
Can you get any property from results returned from a fulltext search even if you dont include it in the index definition?