Is it possible to use Algolia query in FirestoreRecyclerOptions?
To allow my user performing more complex search, I'm working with Algolia.
com.algolia.search.saas.Query algolia_query =
new com.algolia.search.saas.Query(mLastQuery)
.setAttributesToRetrieve("content")
.setAttributesToRetrieve("category")
.setHitsPerPage(10);
index.searchAsync(algolia_query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject jsonObject, AlgoliaException e)
Log.d("algolia", jsonObject.toString());
);
I would like to convert this jsonObject into something compatible with FirestoreRecyclerOptions
to be able to use FirestoreRecyclerAdapter
Thank you !
android google-cloud-firestore
add a comment |
To allow my user performing more complex search, I'm working with Algolia.
com.algolia.search.saas.Query algolia_query =
new com.algolia.search.saas.Query(mLastQuery)
.setAttributesToRetrieve("content")
.setAttributesToRetrieve("category")
.setHitsPerPage(10);
index.searchAsync(algolia_query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject jsonObject, AlgoliaException e)
Log.d("algolia", jsonObject.toString());
);
I would like to convert this jsonObject into something compatible with FirestoreRecyclerOptions
to be able to use FirestoreRecyclerAdapter
Thank you !
android google-cloud-firestore
add a comment |
To allow my user performing more complex search, I'm working with Algolia.
com.algolia.search.saas.Query algolia_query =
new com.algolia.search.saas.Query(mLastQuery)
.setAttributesToRetrieve("content")
.setAttributesToRetrieve("category")
.setHitsPerPage(10);
index.searchAsync(algolia_query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject jsonObject, AlgoliaException e)
Log.d("algolia", jsonObject.toString());
);
I would like to convert this jsonObject into something compatible with FirestoreRecyclerOptions
to be able to use FirestoreRecyclerAdapter
Thank you !
android google-cloud-firestore
To allow my user performing more complex search, I'm working with Algolia.
com.algolia.search.saas.Query algolia_query =
new com.algolia.search.saas.Query(mLastQuery)
.setAttributesToRetrieve("content")
.setAttributesToRetrieve("category")
.setHitsPerPage(10);
index.searchAsync(algolia_query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject jsonObject, AlgoliaException e)
Log.d("algolia", jsonObject.toString());
);
I would like to convert this jsonObject into something compatible with FirestoreRecyclerOptions
to be able to use FirestoreRecyclerAdapter
Thank you !
android google-cloud-firestore
android google-cloud-firestore
asked Apr 1 '18 at 9:20
Kmel
135112
135112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
For a better understanding, I'll try to explain this with an example. Let's assume we have a FirebaseFirestore
object that points to the root reference of the database and a CollectionReference
object that points to a collection named products
. And for that we can use the following two lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference productsRef = rootRef.collection("products");
Let's aslo assume we have a Cloud Firestore database that looks like this:
Firestore-root
|
--- products
|
--- productIdOne
| |
| --- productName: "Milk"
|
--- productIdTwo
|
--- productName: "Soy Milk"
|
--- productIdThree
|
--- productName: "Bacon"
To achieve this structure, let's add these products to the database and also the corresponding indexes, using the code below:
Map<String, Object> mapOne = new HashMap<>();
mapOne.put("productName", "Milk");
Map<String, Object> mapTwo = new HashMap<>();
mapTwo.put("productName", "Soy Milk");
Map<String, Object> mapThree = new HashMap<>();
mapThree.put("productName", "Bacon");
WriteBatch writeBatch = rootRef.batch();
writeBatch.set(productsRef.document(), mapOne);
writeBatch.set(productsRef.document(), mapTwo);
writeBatch.set(productsRef.document(), mapThree);
writeBatch.commit();
Client client = new Client(YourApplicationID, YourAPIKey);
Index index = client.getIndex("products");
List<JSONObject> productList = new ArrayList<>();
productList.add(new JSONObject(mapOne));
productList.add(new JSONObject(mapTwo));
productList.add(new JSONObject(mapThree));
index.addObjectsAsync(new JSONArray(productList), null);
Let's also assume we have 2 views in out layout file, an EditText
and a ListView
.
EditText editText = findViewById(R.id.edit_text);
ListView listView = findViewById(R.id.list_view);
To actually display those products in our ListView
, let's use the following code:
productsRef.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
List<String> list = new ArrayList<>();
for (DocumentSnapshot document : task.getResult())
list.add(document.getString("productName"));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
else
Log.d(TAG, "Error getting documents: ", task.getException());
);
In order to filter the products according to the text that we type in our EditText
, we need to add a TextChangedListener
like this:
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void afterTextChanged(Editable editable)
Query query = new Query(editable.toString())
.setAttributesToRetrieve("productName")
.setHitsPerPage(50);
index.searchAsync(query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject content, AlgoliaException error)
try
JSONArray hits = content.getJSONArray("hits");
List<String> list = new ArrayList<>();
for (int i = 0; i < hits.length(); i++)
JSONObject jsonObject = hits.getJSONObject(i);
String productName = jsonObject.getString("productName");
list.add(productName);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
catch (JSONException e)
e.printStackTrace();
);
);
So in order to make it work, we have created a new adapter object. This means that for every character that we type in the EditText
, we create a new adapter and we populate this adapter with the results that are coming from the database. And to answer your question, in order to achieve what you want, you don't have to change the JSONObject
, you have create a new query object that should be passed to the setQuery()
method that is called on the FirestoreRecyclerOptions
object. I just gave you a simpler example to understand the flow. For more information, I also recommend you see this video.
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
add a comment |
There is no connection between FirebaseUI and Algolia. If you want to show search results from Algolia, you'll have to build an adapter yourself.
You could consider using FirebaseUI's FirebaseIndexedArray
for inspiration. But fair warning: both its internals, and the modifications needed, are quite involved.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f49596610%2fis-it-possible-to-use-algolia-query-in-firestorerecycleroptions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
For a better understanding, I'll try to explain this with an example. Let's assume we have a FirebaseFirestore
object that points to the root reference of the database and a CollectionReference
object that points to a collection named products
. And for that we can use the following two lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference productsRef = rootRef.collection("products");
Let's aslo assume we have a Cloud Firestore database that looks like this:
Firestore-root
|
--- products
|
--- productIdOne
| |
| --- productName: "Milk"
|
--- productIdTwo
|
--- productName: "Soy Milk"
|
--- productIdThree
|
--- productName: "Bacon"
To achieve this structure, let's add these products to the database and also the corresponding indexes, using the code below:
Map<String, Object> mapOne = new HashMap<>();
mapOne.put("productName", "Milk");
Map<String, Object> mapTwo = new HashMap<>();
mapTwo.put("productName", "Soy Milk");
Map<String, Object> mapThree = new HashMap<>();
mapThree.put("productName", "Bacon");
WriteBatch writeBatch = rootRef.batch();
writeBatch.set(productsRef.document(), mapOne);
writeBatch.set(productsRef.document(), mapTwo);
writeBatch.set(productsRef.document(), mapThree);
writeBatch.commit();
Client client = new Client(YourApplicationID, YourAPIKey);
Index index = client.getIndex("products");
List<JSONObject> productList = new ArrayList<>();
productList.add(new JSONObject(mapOne));
productList.add(new JSONObject(mapTwo));
productList.add(new JSONObject(mapThree));
index.addObjectsAsync(new JSONArray(productList), null);
Let's also assume we have 2 views in out layout file, an EditText
and a ListView
.
EditText editText = findViewById(R.id.edit_text);
ListView listView = findViewById(R.id.list_view);
To actually display those products in our ListView
, let's use the following code:
productsRef.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
List<String> list = new ArrayList<>();
for (DocumentSnapshot document : task.getResult())
list.add(document.getString("productName"));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
else
Log.d(TAG, "Error getting documents: ", task.getException());
);
In order to filter the products according to the text that we type in our EditText
, we need to add a TextChangedListener
like this:
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void afterTextChanged(Editable editable)
Query query = new Query(editable.toString())
.setAttributesToRetrieve("productName")
.setHitsPerPage(50);
index.searchAsync(query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject content, AlgoliaException error)
try
JSONArray hits = content.getJSONArray("hits");
List<String> list = new ArrayList<>();
for (int i = 0; i < hits.length(); i++)
JSONObject jsonObject = hits.getJSONObject(i);
String productName = jsonObject.getString("productName");
list.add(productName);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
catch (JSONException e)
e.printStackTrace();
);
);
So in order to make it work, we have created a new adapter object. This means that for every character that we type in the EditText
, we create a new adapter and we populate this adapter with the results that are coming from the database. And to answer your question, in order to achieve what you want, you don't have to change the JSONObject
, you have create a new query object that should be passed to the setQuery()
method that is called on the FirestoreRecyclerOptions
object. I just gave you a simpler example to understand the flow. For more information, I also recommend you see this video.
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
add a comment |
For a better understanding, I'll try to explain this with an example. Let's assume we have a FirebaseFirestore
object that points to the root reference of the database and a CollectionReference
object that points to a collection named products
. And for that we can use the following two lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference productsRef = rootRef.collection("products");
Let's aslo assume we have a Cloud Firestore database that looks like this:
Firestore-root
|
--- products
|
--- productIdOne
| |
| --- productName: "Milk"
|
--- productIdTwo
|
--- productName: "Soy Milk"
|
--- productIdThree
|
--- productName: "Bacon"
To achieve this structure, let's add these products to the database and also the corresponding indexes, using the code below:
Map<String, Object> mapOne = new HashMap<>();
mapOne.put("productName", "Milk");
Map<String, Object> mapTwo = new HashMap<>();
mapTwo.put("productName", "Soy Milk");
Map<String, Object> mapThree = new HashMap<>();
mapThree.put("productName", "Bacon");
WriteBatch writeBatch = rootRef.batch();
writeBatch.set(productsRef.document(), mapOne);
writeBatch.set(productsRef.document(), mapTwo);
writeBatch.set(productsRef.document(), mapThree);
writeBatch.commit();
Client client = new Client(YourApplicationID, YourAPIKey);
Index index = client.getIndex("products");
List<JSONObject> productList = new ArrayList<>();
productList.add(new JSONObject(mapOne));
productList.add(new JSONObject(mapTwo));
productList.add(new JSONObject(mapThree));
index.addObjectsAsync(new JSONArray(productList), null);
Let's also assume we have 2 views in out layout file, an EditText
and a ListView
.
EditText editText = findViewById(R.id.edit_text);
ListView listView = findViewById(R.id.list_view);
To actually display those products in our ListView
, let's use the following code:
productsRef.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
List<String> list = new ArrayList<>();
for (DocumentSnapshot document : task.getResult())
list.add(document.getString("productName"));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
else
Log.d(TAG, "Error getting documents: ", task.getException());
);
In order to filter the products according to the text that we type in our EditText
, we need to add a TextChangedListener
like this:
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void afterTextChanged(Editable editable)
Query query = new Query(editable.toString())
.setAttributesToRetrieve("productName")
.setHitsPerPage(50);
index.searchAsync(query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject content, AlgoliaException error)
try
JSONArray hits = content.getJSONArray("hits");
List<String> list = new ArrayList<>();
for (int i = 0; i < hits.length(); i++)
JSONObject jsonObject = hits.getJSONObject(i);
String productName = jsonObject.getString("productName");
list.add(productName);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
catch (JSONException e)
e.printStackTrace();
);
);
So in order to make it work, we have created a new adapter object. This means that for every character that we type in the EditText
, we create a new adapter and we populate this adapter with the results that are coming from the database. And to answer your question, in order to achieve what you want, you don't have to change the JSONObject
, you have create a new query object that should be passed to the setQuery()
method that is called on the FirestoreRecyclerOptions
object. I just gave you a simpler example to understand the flow. For more information, I also recommend you see this video.
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
add a comment |
For a better understanding, I'll try to explain this with an example. Let's assume we have a FirebaseFirestore
object that points to the root reference of the database and a CollectionReference
object that points to a collection named products
. And for that we can use the following two lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference productsRef = rootRef.collection("products");
Let's aslo assume we have a Cloud Firestore database that looks like this:
Firestore-root
|
--- products
|
--- productIdOne
| |
| --- productName: "Milk"
|
--- productIdTwo
|
--- productName: "Soy Milk"
|
--- productIdThree
|
--- productName: "Bacon"
To achieve this structure, let's add these products to the database and also the corresponding indexes, using the code below:
Map<String, Object> mapOne = new HashMap<>();
mapOne.put("productName", "Milk");
Map<String, Object> mapTwo = new HashMap<>();
mapTwo.put("productName", "Soy Milk");
Map<String, Object> mapThree = new HashMap<>();
mapThree.put("productName", "Bacon");
WriteBatch writeBatch = rootRef.batch();
writeBatch.set(productsRef.document(), mapOne);
writeBatch.set(productsRef.document(), mapTwo);
writeBatch.set(productsRef.document(), mapThree);
writeBatch.commit();
Client client = new Client(YourApplicationID, YourAPIKey);
Index index = client.getIndex("products");
List<JSONObject> productList = new ArrayList<>();
productList.add(new JSONObject(mapOne));
productList.add(new JSONObject(mapTwo));
productList.add(new JSONObject(mapThree));
index.addObjectsAsync(new JSONArray(productList), null);
Let's also assume we have 2 views in out layout file, an EditText
and a ListView
.
EditText editText = findViewById(R.id.edit_text);
ListView listView = findViewById(R.id.list_view);
To actually display those products in our ListView
, let's use the following code:
productsRef.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
List<String> list = new ArrayList<>();
for (DocumentSnapshot document : task.getResult())
list.add(document.getString("productName"));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
else
Log.d(TAG, "Error getting documents: ", task.getException());
);
In order to filter the products according to the text that we type in our EditText
, we need to add a TextChangedListener
like this:
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void afterTextChanged(Editable editable)
Query query = new Query(editable.toString())
.setAttributesToRetrieve("productName")
.setHitsPerPage(50);
index.searchAsync(query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject content, AlgoliaException error)
try
JSONArray hits = content.getJSONArray("hits");
List<String> list = new ArrayList<>();
for (int i = 0; i < hits.length(); i++)
JSONObject jsonObject = hits.getJSONObject(i);
String productName = jsonObject.getString("productName");
list.add(productName);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
catch (JSONException e)
e.printStackTrace();
);
);
So in order to make it work, we have created a new adapter object. This means that for every character that we type in the EditText
, we create a new adapter and we populate this adapter with the results that are coming from the database. And to answer your question, in order to achieve what you want, you don't have to change the JSONObject
, you have create a new query object that should be passed to the setQuery()
method that is called on the FirestoreRecyclerOptions
object. I just gave you a simpler example to understand the flow. For more information, I also recommend you see this video.
For a better understanding, I'll try to explain this with an example. Let's assume we have a FirebaseFirestore
object that points to the root reference of the database and a CollectionReference
object that points to a collection named products
. And for that we can use the following two lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference productsRef = rootRef.collection("products");
Let's aslo assume we have a Cloud Firestore database that looks like this:
Firestore-root
|
--- products
|
--- productIdOne
| |
| --- productName: "Milk"
|
--- productIdTwo
|
--- productName: "Soy Milk"
|
--- productIdThree
|
--- productName: "Bacon"
To achieve this structure, let's add these products to the database and also the corresponding indexes, using the code below:
Map<String, Object> mapOne = new HashMap<>();
mapOne.put("productName", "Milk");
Map<String, Object> mapTwo = new HashMap<>();
mapTwo.put("productName", "Soy Milk");
Map<String, Object> mapThree = new HashMap<>();
mapThree.put("productName", "Bacon");
WriteBatch writeBatch = rootRef.batch();
writeBatch.set(productsRef.document(), mapOne);
writeBatch.set(productsRef.document(), mapTwo);
writeBatch.set(productsRef.document(), mapThree);
writeBatch.commit();
Client client = new Client(YourApplicationID, YourAPIKey);
Index index = client.getIndex("products");
List<JSONObject> productList = new ArrayList<>();
productList.add(new JSONObject(mapOne));
productList.add(new JSONObject(mapTwo));
productList.add(new JSONObject(mapThree));
index.addObjectsAsync(new JSONArray(productList), null);
Let's also assume we have 2 views in out layout file, an EditText
and a ListView
.
EditText editText = findViewById(R.id.edit_text);
ListView listView = findViewById(R.id.list_view);
To actually display those products in our ListView
, let's use the following code:
productsRef.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>()
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task)
if (task.isSuccessful())
List<String> list = new ArrayList<>();
for (DocumentSnapshot document : task.getResult())
list.add(document.getString("productName"));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
else
Log.d(TAG, "Error getting documents: ", task.getException());
);
In order to filter the products according to the text that we type in our EditText
, we need to add a TextChangedListener
like this:
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void afterTextChanged(Editable editable)
Query query = new Query(editable.toString())
.setAttributesToRetrieve("productName")
.setHitsPerPage(50);
index.searchAsync(query, new CompletionHandler()
@Override
public void requestCompleted(JSONObject content, AlgoliaException error)
try
JSONArray hits = content.getJSONArray("hits");
List<String> list = new ArrayList<>();
for (int i = 0; i < hits.length(); i++)
JSONObject jsonObject = hits.getJSONObject(i);
String productName = jsonObject.getString("productName");
list.add(productName);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
catch (JSONException e)
e.printStackTrace();
);
);
So in order to make it work, we have created a new adapter object. This means that for every character that we type in the EditText
, we create a new adapter and we populate this adapter with the results that are coming from the database. And to answer your question, in order to achieve what you want, you don't have to change the JSONObject
, you have create a new query object that should be passed to the setQuery()
method that is called on the FirestoreRecyclerOptions
object. I just gave you a simpler example to understand the flow. For more information, I also recommend you see this video.
edited Apr 2 '18 at 19:04
answered Apr 2 '18 at 8:24
Alex Mamo
39k72759
39k72759
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
add a comment |
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Is there everything alright? Have you tried my solution above?
– Alex Mamo
Apr 4 '18 at 7:34
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
Hello! Indeed, I build my own RecyclerView adapter to display search from Algolia. Your answer and the one from Frank van Puffelen helped me to achieve what I want. Thanks!
– Kmel
Apr 5 '18 at 14:22
add a comment |
There is no connection between FirebaseUI and Algolia. If you want to show search results from Algolia, you'll have to build an adapter yourself.
You could consider using FirebaseUI's FirebaseIndexedArray
for inspiration. But fair warning: both its internals, and the modifications needed, are quite involved.
add a comment |
There is no connection between FirebaseUI and Algolia. If you want to show search results from Algolia, you'll have to build an adapter yourself.
You could consider using FirebaseUI's FirebaseIndexedArray
for inspiration. But fair warning: both its internals, and the modifications needed, are quite involved.
add a comment |
There is no connection between FirebaseUI and Algolia. If you want to show search results from Algolia, you'll have to build an adapter yourself.
You could consider using FirebaseUI's FirebaseIndexedArray
for inspiration. But fair warning: both its internals, and the modifications needed, are quite involved.
There is no connection between FirebaseUI and Algolia. If you want to show search results from Algolia, you'll have to build an adapter yourself.
You could consider using FirebaseUI's FirebaseIndexedArray
for inspiration. But fair warning: both its internals, and the modifications needed, are quite involved.
answered Apr 1 '18 at 14:48
Frank van Puffelen
227k28372397
227k28372397
add a comment |
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%2f49596610%2fis-it-possible-to-use-algolia-query-in-firestorerecycleroptions%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