I am developing an web app using Codeigniter and MongoDB. Users can save their favorites sounds in as "bookmarks". Each user get one document and then each sound is appended to an array in that document called sounds. Each sound got a set of tags that is also saved to the bookmark. How can I search a users bookmarks in their bookmark document? I want them to be able to search by tags (from the tag array).
This is my MongoDB document:
{
"_id": ObjectId("4f15846a112bf6b725000000"),
"owner": {
"user_id": ObjectId("4f147e1709ab662061000000"),
"session_id": "3424e3155a01e78c50a8498f78cc51d9"
},
"sound_files": [
{
"sound_id": ObjectId("4f1480ff09ab661a61000001"),
"sound_url": "http://s3.amazonaws.com/4c/864ea8e92e6ec4408e248cc9brf008bd/18.wav",
"sound_tags": [
"sound",
"new york",
"cool"
]
},
{
"sound_id": ObjectId("4f1480ff09ab661a61000001"),
"sound_url": "http://s3.amazonaws.com/4c/864ea8e92e6ec4408e248cc9brf008bd/12.wav",
"sound_tags": [
"sound",
"happy",
"ocean"
]
}
],
"total": 1
}
db.col.find({'sound_files.sound_tags':"sound"})
EDIT: Not exactly what OP is looking for apparently. Waiting for a more precise description of the requirement.
Related
I am trying to create an adaptive card for an elastic alert. The payload I receive for the card kind of looks like the following json:
{
"hits": {
"max_score": null,
"hits": [
{
"fields": {
"log.#m":
"some log message"
,
"kubernetes.node.name": [
"node name"
],
"log.#l": [
"Error"
]
}
}
]
}
}
I, however, have some problems getting the fields into a TextBlock because of the dot notation or the .# in the fields names. If I remove them (only possible in the adaptive card designer with the sample data editor) I can display the data just fine. It is not possible to change the property names since this is an Elastic thing.
I tried a lot of possibilities for the text field.
through the UI editor
using [] brackets
using single quotes
combinations of the above...
{
"type": "Container",
"items": [
{
"$when": "${$index < 2}",
"type": "TextBlock",
"text": "${log.m}",
"$data": "${fields}"
}
],
"$data": "${$root.hits.hits}"
}
Does anyone have an idea how I could go about displaying the fields in a textblock?
I am quite new to graphQL, and after searching the whole afternoon, i didn't found my answer to a relative quite simple problem.
I have two objects in my strapi backend :
"travels": [
{
"id": "1",
"title": "Bolivia: La Paz y Salar de Uyuni",
"travel_types": [
{
"name": "Culturales"
},
{
"name": "Aventura"
},
{
"name": "Ecoturismo"
}
]
},
{
"id": "2",
"title": "Europa clásica 2020",
"travel_types": [
{
"name": "Clasicas"
},
{
"name": "Culturales"
}
]
}
]
I am trying to get a filter where I search for travels containing ALL the user-selected travel_types.
I then wrote a query like that :
query($where: JSON){
travels (where:$where) {
id # Or _id if you are using MongoDB
title
travel_types {name}
}
And the parameter i try to input for testing :
{
"where":{
"travel_types.name_contains": ["Aventura"],
"travel_types.name_contains": ["Clasicas"]
}
}
This should return an empty array, because none of the travels have both Aventura and Clasicas travel-types.
But instead it returns the travel with id=2. It seems that only the second filter is taken.
I searched for a query which would be like Array.every() in javascript, but i wasn't able to find.
Does someone has an idea how to achieve this type of filtering ?
Thank you very much,
Let's say I have users index and blogs index. Now I want to enable users to create posts on by blog.
My first thought is that this is how my index should look like:
{
"title": "Blog post title",
"content": "Post text",
"user": {
"username": "lala",
"name": "Johnny",
"birthday": "1991-29-12"
}
}
Which looks good. But what if user changes his name and birthday. Then I need to go through all blog posts and update "user" object?
What if that needs to happen with multiple indexes?
How should I store data like this?
I need to import google contacts to my application. For that I try to use the Google People API but I didn't find an option to get the contacts custom fields.
Is it possible to get contact custom fields with the new Google People API?
Should I use the old Google Contacts API for that?
Thanks!
Request the userDefined projection with your personFields.
String url = "https://people.googleapis.com/v1/people/me/connections" +
"?personFields=names,emailAddresses,userDefined";
The response looks like this:
"userDefined": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "5629e24b082d1a66"
}
},
"key": "label1",
"value": "foo"
},
{
"metadata": {
"source": {
"type": "CONTACT",
"id": "5629e24b082d1a66"
}
},
"key": "label2",
"value": "bar"
}
]
For more details, see https://developers.google.com/people/api/rest/v1/people#Person.UserDefined
You can also update custom fields even though the documentation does not currently list userDefined as a valid field for updatePersonFields as the field mask.
https://developers.google.com/people/api/rest/v1/people/updateContact
How can I only return results which have a notable type?
IE when I have the default example:
https://www.googleapis.com/freebase/v1/search?query=nirvana&indent=true
It normally returns something like:
{
"mid": "/m/015k7",
"name": "Gautama Buddha",
"notable": {
"name": "Deity",
"id": "/religion/deity"
},
"lang": "en",
"score": 24.125902
}...
which is perfect, but sometimes it doesn't have a notable type and returns only:
{
"mid": "/m/01rkx5",
"name": "Mahayana Mahaparinirvana Sutra",
"lang": "en",
"score": 22.350945
},
How can i filter out all results except those that have a notable type?
I tried setting
filter = (all notable) but it expects (all notable:something)
any ideas?
Currently, its not possible to filter search results based on whether notable types exists. I've passed your suggestion on to the Freebase engineers and they'll considering whether to add this in a future release of the Search API.