-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.27 facetsDistribution behavior changed on empty response #2352
Comments
@gmourier is this behavior in the specs? A thing like this "all the required attributes in Also can we add tests about this behavior? 🔥 |
I can confirm! It is used natively by instantsearch to generate the facet UI. Without it, the component does not render |
{
"id": "the best doggo",
"doggo": {
"name": "bob",
"race": "bernese mountain",
"picture": "https://thewoofclub.ch/wp-content/uploads/2020/09/bernese-puppy.png"
}
} If I ask the field distribution for {
"doggo": {},
"doggo.name": { "bob": 1 },
"doggo.race": { "bernese mountain": 1 },
"doggo.picture": { "https://thewoofclub.ch/wp-content/uploads/2020/09/bernese-puppy.png": 1 },
} Or {
"doggo.name": { "bob": 1 },
"doggo.race": { "bernese mountain": 1 },
"doggo.picture": { "https://thewoofclub.ch/wp-content/uploads/2020/09/bernese-puppy.png": 1 },
} Or {
"doggo": {},
}
? EDIT: MY EXAMPLES WERE BROKEN |
For me, the example 1 is the best thing to do in this case because you could have a non-nested This will happen in case a user has set It is typically for this type of behavior that |
I m not sure I understand the context. Was I'm a bit lost. |
Yep otherwise it would have thrown an error at search.
In this case, it will return documents having a simple field
This is the last one, In any case, the engine just tries to adapt as best as possible to the fact that a schema does not exist. If you specify We can expect that a majority of users will not mix documents having different representations for a field. |
This is problematic as instant-search uses facetsDistribution to create components and excepts at all time a Another inconsistency is that the following implies that
that output makes the most sense for me:
and if you have results:
|
You can reproduce it the following way:
const { MeiliSearch } = require('meilisearch')
;(async () => {
const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
const index = client.index('movies')
const dataset = [
{ id: 1, title: 'Carol' },
{ id: 2, title: 'Wonder Woman', genres: ['Action', 'Adventure'] },
{ id: 3, title: 'Life of Pi', genres: ['Adventure', 'Drama'] },
{ id: 4, title: 'Mad Max: Fury Road', genres: ['Adventure', 'Science Fiction'] },
{ id: 5, title: 'Moana', genres: ['Fantasy', 'Action']},
{ id: 6, title: 'Philadelphia', genres: ['Drama'] },
]
await index.updateFilterableAttributes([
'genres'
])
let { uid } = await index.addDocuments(dataset)
await client.waitForTask(uid)
const filteredSearch = await index.search('Carol', {
facetsDistribution: ["genres"]
})
console.log({ filteredSearch, hit: filteredSearch.hits[0] })
})()
Try with v0.26 and v0.27 |
In this example, your documents contains a |
I made a search on |
I managed to reproduce it @irevoire. Here is the behavior of v0.26.0:
|
If we have to talk about the behavior of nested fields with facetsDistribution, please make another issue if the current behavior is not good after the bug has been fixed for the sake of clarity. We wasted a lot of time responding and trying to figure out the bug which was not related to the nested field support feature initially. It seems that we introduced a design question in the bug ticket which was already miss understood! Thanks 😇 |
I'm not sure it is wasted as it raised an important other issue! But I will create an a part issue for this :) EDIT: I did not see tamo's edit. Indeed the behavior is the one expected! Good for me |
I apologize, my previous message can sound a bit harsh. The word "wasted" sounds bigger than what I wanted to express. We finally managed to understand each other, I just understood the fact that the format of the nested example was wrong. Thank you for reporting this bug and giving instructions so we can reproduce it @bidoubiwa! 🙌 |
518: Return facets even when there is no value associated to it r=Kerollmops a=Kerollmops This PR is related to meilisearch/meilisearch#2352 and should fix the issue when Meilisearch is up-to-date with this PR. Co-authored-by: Kerollmops <clement@meilisearch.com>
Closed by #2366 |
Describe the bug
In v0.26 when a search was made with the facetsDistribution set to
genres
for example, even when the returned hits contained no hits containedgenres
the facets distribution value was:with the v0.27 it becomes:
Works in:
but not in:
To Reproduce
Steps to reproduce the behavior:
genres
in thefilterableAttributes
of an empty index.{ "id": 1, "title": "hello" }
facetDistribution
set to["genres"]
facetsDistribution: {}
Expected behavior
Same behavior as before
Meilisearch version: [e.g. v0.20.0]
v0.27.0rc2
The text was updated successfully, but these errors were encountered: