Define field to search on at search-time #107
Replies: 27 comments 26 replies
-
Hello @aaqibjavith, Thanks for this question. What you want is totally possible with MeiliSearch by changing your |
Beta Was this translation helpful? Give feedback.
-
@qdequele The documentation says we need to update index settings through /indexes/:index_uid/settings/searchable-attributes. But we don't want to limit the searchable attribute in the index level. We have fields such as location, role, plan, and many more attributes. When our customer types "a" in the location field, I want to list all the locations starts with "a", not from role and plan. Similarly, we need an autocomplete feature for other fields such as role, plan, etc. Also, note that we have 1000+ customers who use our autocomplete features on different fields. That's why I said, index level setting won't work for us. We need these settings per-query basis. |
Beta Was this translation helpful? Give feedback.
-
Could filtering be an option? |
Beta Was this translation helpful? Give feedback.
-
@CaroFG Thanks for the doc. This is interesting. Here I see that filters are applied along with query string. In our case, we want autocomplete on certain fields. Is it possible to give regex like string "*uni*" in the filter field? |
Beta Was this translation helpful? Give feedback.
-
I'm sorry @aaqibjavith, I'm afraid filtering is not the right solution for you. I thought you could use placeholder search combined with filtering but filtering will only return exact matches, it doesn't support regex either. I'm not quite sure why the searchable attribute option doesn't work for you, if you only want to search for the location, you can still display all the attributes you want while only searching on location. (searchableAttributes vs displayedAttributes) In any case, you can always add your ideas to the roadmap if they aren't already there :) |
Beta Was this translation helpful? Give feedback.
-
I think I have same question. e.g. I want to search "fight" only in the title field (not in the description field) while search "happy" in only description (not in the title field) on a same index. I think any of searchableAttributes, filters or facetFilters is not an option for this situation. |
Beta Was this translation helpful? Give feedback.
-
Just an idea, [
{ "id": "001-title", "movie_id": "001", "text": "Fight club'", "field": "title" },
{ "id": "001-desc", "movie_id": "001", "text": "description of the movie...'", "field": "desc" },
....
] I think I can search in only title by filter: "field = title". |
Beta Was this translation helpful? Give feedback.
-
@qdequele, what a great tool, with easy setup, thanks. This is one of the first things I was trying to do - essentially search a specific attribute or set of attributes in a single index. Say I have a few attributes - id, name, keywords and author. If I want to search for 'Novel' in name, I could use a filter, but this would only return an exact match as I understand it. If I want to take advantage of non-exact matches, I could create a new index that has searchableAttributes set to name, and use that, but then would need several indexes to handle the different permutations ([name, keywords], [name, author], [author, keywords]) and so on -which could be rather a lot of indexes. Wildcards in the filters may work for this, or perhaps sending the searchableAttribute(s) that you want to use at query time? I can see a card in the roadmap for allowing filters to have wildcards, but I am not sure due to the architecture if querytime searchableAttributes would be possible? @hiroshi idea could also be a good workaround at the moment, but could mean many multiples of records. |
Beta Was this translation helpful? Give feedback.
-
hello @Keoghan! For the moment it is indeed not possible to define the searchable attributes during the query time sorry. |
Beta Was this translation helpful? Give feedback.
-
Thank you @curquiza, for now I have used an alternative search solution 👍 |
Beta Was this translation helpful? Give feedback.
-
Being able to choose which fields to query by at search time would be awesome. It doesn't have to be per term. Algolia supports this with the Typesense supports this with the |
Beta Was this translation helpful? Give feedback.
-
Hello everyone 👋 We've moved the product discussions to a dedicated repository. I'd like to ask you some questions to better understand the needs behind these requests. Why do you want to do this at the time of the search? Reading some of the posts here, I get the impression that based on a term typed by the end-user you would like to be able to make the searchableAttributes dynamic at search time. I imagine that this particular need arises because depending on the user journey within your products you would like to emphasize certain fields rather than others but I may be wrong. I'm really curious to know what brings you to this particular need. Thank you for your answers and help |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I + this. I was very confused that this wasn't already a thing when looking at the docs, considering we can already search by all the searchable attributes. It's probably way more complicated than it seems to me, but for the time being wouldn't Meili be able to simply ignore results that don't have a match in some specified desired attributes? Would it add too much delay, and/or/because it's not as simple because of how limit and offset works? I could make this work by doing manual filtration (I think), but I don't know if it's worth the time, both in work and delay it adds to search (because I'd have to possibly make more than several calls to the API, as opposed to it being an internal thing). |
Beta Was this translation helpful? Give feedback.
-
Hi there! What is described by @Sembiance above, is very similar to our use case. For example, we want to give the ability to our users to search for hotels in a specific country, and thus, be able to specify dynamically the |
Beta Was this translation helpful? Give feedback.
-
+1 for this, this is also the first thing I tried achieving with Meilisearch and it's too bad this is not supported. My usecase: Ecommerce platform with 3 supported languages. My products have translated attributes, where "title" is 1 of them. There is a search bar in my navigation that let's the user search products. Currently, when a user would search a product on the FR website, Meilisearch is returning documents that match the given searchquery on all "title_*" fields. A very simple ( on our end of course :) ) would be to able to restrict the attributes where the search is performed upon. There, I should be able to only search on "title_fr". I can't imagine this not being a high priority. For perfomance reasons, it makes sense to store attributes in Meilisearch on which you don't even wan't to search, because afterwards you don't have to refetch them from your database. Like for building a product list, I could use my info from my Meilisearch index directly, and not have to load all my models from the database after my search. |
Beta Was this translation helpful? Give feedback.
-
Agree this would be really useful for me. I have a platform with posts containing metadata on each image for a "camera", "lens", and "film" in one object. While a user might have a Leica camera they might have a Minolta lens that they took the image with so being able to filter by a specific attribute at the time of search would really help. So that a search for Camera: 'Minolta' does not include facet results from a post that has a Minolta lens. Currently the facetDistribution would return 'Leica' for that query. At present I have to break out each of the 3 pieces of metadata into their own shallow index of what could just be a single post index in order to maintain specific search rules for each query. |
Beta Was this translation helpful? Give feedback.
-
Agree, we have a usecase where we have nested objects in our documents, sometimes the users need to search only for names in an array of objects that exists under all documents. Simple exampleWe have two construction firms, each firm has several construction sites, our users have the need to be able to search trough all construction sites on a specific field. This could be solved by having two indexes but the problem is the users want the results of all construction firms that have sites with a certain text, having to search first in the sites index and then try to link this by getting all construction firms is not ideal. Handling the results locally after the results are returned is not ideal either. In the [
{
"name": "Foo's construction",
"sites": [
{
"name": "Foo's construction site 1",
"address": "Site address 12"
},
{
"name": "Foo's construction site 2",
"address": "Site address 1"
}
]
},
{
"name": "Bar's construction",
"sites": [
{
"name": "Bar's construction site 1",
"address": "Site address 1"
},
{
"name": "Bar's construction site 2",
"address": "Site address 55"
}
]
}
] Having this feature implemented would allow users to choose if they want to do very specific searches for data. And it would provide much more flexibility. Extra ideaThis could also be a feature in the tenant token's |
Beta Was this translation helpful? Give feedback.
-
Could anyone from the Meilisearch team chime in on this? Without this feature (which both your competitors have) several folks (including myself) cannot use Meilisearch. Seems like it should get bumped up the priority list :) |
Beta Was this translation helpful? Give feedback.
-
This is an actual use case; I am also stuck here. |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
While this would be useful, I think the searching for facet values feature helps a lot. It makes for a two stage search, where we autocomplete the value, then submit the search with the exact match filter, which isn't too bad. You could even fake this feature by taking the facet search response, then submitting all variations to the filter, which simulates the full-text search people are looking for. Not sure how well Meilisearch would handle potentially hundreds or thousands of filter values |
Beta Was this translation helpful? Give feedback.
-
Hello everyone! 👋 Quick update: we've started working on a solution to define searchable fields at search-time. Stay tuned for updates, and feel free to keep the feedback coming! |
Beta Was this translation helpful? Give feedback.
-
Hello everyone 👋 We just released a 🧪 prototype that allows Meilisearch to define searchable fields at runtime. You can now use a new search parameter How to get the prototype?Using docker, use the following command:
From source, compile Meilisearch on the How to use the prototype?You can find an example below, or look at the original PR for more info. This feature allows the end-user to search in one or multiple attributes using the search parameter
This feature act like a filter, forcing Meilisearch only to return the documents containing the requested words in the restricted Attributes. Note that, with the matching strategy last, Meilisearch will only ensure that the first word is in the restricted Attributes, but the retrieved documents will be ordered considering the word contained in the restricted attributes. Questions we have for you
Feedback and bug reporting when using this prototype are encouraged! Thanks in advance for your involvement. It means a lot to us ❤️ |
Beta Was this translation helpful? Give feedback.
-
Hello everyone 👋 We have just released the first RC (release candidate) of Meilisearch containing this new feature! docker run -it --rm -p 7700:7700 -v $(pwd)/meili_data:/meili_data getmeili/meilisearch:v1.3.0-rc.0 You are welcome to leave your feedback in this discussion. If you encounter any bugs, please report them here. 🎉 The official and stable release containing this change will be available on July 31st, 2023 |
Beta Was this translation helpful? Give feedback.
-
Hey folks 👋 v1.3 has been released! 🦁 You can now define fields to search on at search time ✨ Note: Attributes passed to attributesToSearchOn must be in the searchable attributes list. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
We have 10M users database where we would like to search only by location field. Currently using facetFilters, I can search for an exact match. In our case, if we type "a", we would like to get all available locations starting with "a".
By the way, We don't want to search in all fields and also don't want to set attributesForFaceting at the index level.
Describe the solution you'd like
We like to limit the search attribute during search calls.
Is it possible now?
Beta Was this translation helpful? Give feedback.
All reactions