Cloud Firestore: check if value exists without knowing field name
up vote
0
down vote
favorite
I would like to check if a certain value is present in my Cloud Firestore collection through all the present fields and have back the document ID that has at least one field whose value is the one searched.
In this example, the code should give back only 2 records when I look for "Peter"
: 8cyMJG7uNgVoenA63brG
and fnk0kgW7gSBc3EdOYWxD
.
I know how to do a search when the field name is known. But in this case, I cannot know the field name at prior.
google-cloud-firestore
add a comment |
up vote
0
down vote
favorite
I would like to check if a certain value is present in my Cloud Firestore collection through all the present fields and have back the document ID that has at least one field whose value is the one searched.
In this example, the code should give back only 2 records when I look for "Peter"
: 8cyMJG7uNgVoenA63brG
and fnk0kgW7gSBc3EdOYWxD
.
I know how to do a search when the field name is known. But in this case, I cannot know the field name at prior.
google-cloud-firestore
In your example, "Peter" is in theAddress
property and in the second inName
. In how many others can be? Do you need an exact match orPeter Pan
should also be a match?
– Alex Mamo
Nov 12 at 17:59
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to check if a certain value is present in my Cloud Firestore collection through all the present fields and have back the document ID that has at least one field whose value is the one searched.
In this example, the code should give back only 2 records when I look for "Peter"
: 8cyMJG7uNgVoenA63brG
and fnk0kgW7gSBc3EdOYWxD
.
I know how to do a search when the field name is known. But in this case, I cannot know the field name at prior.
google-cloud-firestore
I would like to check if a certain value is present in my Cloud Firestore collection through all the present fields and have back the document ID that has at least one field whose value is the one searched.
In this example, the code should give back only 2 records when I look for "Peter"
: 8cyMJG7uNgVoenA63brG
and fnk0kgW7gSBc3EdOYWxD
.
I know how to do a search when the field name is known. But in this case, I cannot know the field name at prior.
google-cloud-firestore
google-cloud-firestore
edited Nov 11 at 21:16
Doug Stevenson
67.2k87998
67.2k87998
asked Nov 11 at 20:56
Stefano
11118
11118
In your example, "Peter" is in theAddress
property and in the second inName
. In how many others can be? Do you need an exact match orPeter Pan
should also be a match?
– Alex Mamo
Nov 12 at 17:59
add a comment |
In your example, "Peter" is in theAddress
property and in the second inName
. In how many others can be? Do you need an exact match orPeter Pan
should also be a match?
– Alex Mamo
Nov 12 at 17:59
In your example, "Peter" is in the
Address
property and in the second in Name
. In how many others can be? Do you need an exact match or Peter Pan
should also be a match?– Alex Mamo
Nov 12 at 17:59
In your example, "Peter" is in the
Address
property and in the second in Name
. In how many others can be? Do you need an exact match or Peter Pan
should also be a match?– Alex Mamo
Nov 12 at 17:59
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
If you don't know the name of a field, you can't perform any queries against its value. Firestore requires queries to use some index, and indexes always work with the names of fields in your documents.
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
If you don't know the name of a field, you can't perform any queries against its value. Firestore requires queries to use some index, and indexes always work with the names of fields in your documents.
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
add a comment |
up vote
0
down vote
accepted
If you don't know the name of a field, you can't perform any queries against its value. Firestore requires queries to use some index, and indexes always work with the names of fields in your documents.
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
If you don't know the name of a field, you can't perform any queries against its value. Firestore requires queries to use some index, and indexes always work with the names of fields in your documents.
If you don't know the name of a field, you can't perform any queries against its value. Firestore requires queries to use some index, and indexes always work with the names of fields in your documents.
answered Nov 11 at 21:16
Doug Stevenson
67.2k87998
67.2k87998
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
add a comment |
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I know the name of the collection. But I have to look through all the fields of that collection.
– Stefano
Nov 12 at 8:41
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
I understand that. You can't do that with a Firestore query. Probably you need a full text search engine instead.
– Doug Stevenson
Nov 12 at 8:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253158%2fcloud-firestore-check-if-value-exists-without-knowing-field-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In your example, "Peter" is in the
Address
property and in the second inName
. In how many others can be? Do you need an exact match orPeter Pan
should also be a match?– Alex Mamo
Nov 12 at 17:59