pdphilip / laravel-elasticsearch

Laravel Elasticsearch: An Elasticsearch implementation of Laravel's Eloquent ORM
MIT License
86 stars 16 forks source link

Added the ability to sort for non-existent fields and fixed connection error #36

Closed ildar-developer closed 1 week ago

pdphilip commented 2 weeks ago

Thanks @ildar-developer

PRs are welcome and encouraged. Basic etiquette though is to at least describe your contribution (beyond the title) to provide context for us maintainers.

Please do so by:

Thanks!

ildar-developer commented 2 weeks ago

I'm sorting by merchandising, and not all products have the merchandising property; if you don't specify unmapped_type, elastic will complain. I added the ability to add unmapped_type

ildar-developer commented 2 weeks ago

the second point is related to the fact that we cannot use 2 models since connect is 1 for two, so I specified clone for getConnection

pdphilip commented 2 weeks ago

As per my last message:

  • If there was an issue, provide examples so that we can try to recreate it ourselves.
ildar-developer commented 2 weeks ago

Data structure: [{ "id": 1544837, "offer_id": 1363809, "price": "11000.00", "price_not_discount": "22000.00", "available_quantity": 1, "discount_percent": 50, "store": { "id": 31, "name": "Rich Classic Women" } }, { "id": 2954243, "offer_id": 1363809, "price": "11000.00", "price_not_discount": "22000.00", "available_quantity": 0, "discount_percent": 50, "store": { "id": 3, "name": "IM VipAvenue" } }],

Снимок экрана 2024-08-29 в 19 09 32

There will be an error because merchandising.sale does not exist

Снимок экрана 2024-08-29 в 19 13 32

Correction method

Снимок экрана 2024-08-29 в 19 21 51 Снимок экрана 2024-08-29 в 19 22 14 Снимок экрана 2024-08-29 в 19 24 09
ildar-developer commented 2 weeks ago

Second error, try making a request in 2 modules

Снимок экрана 2024-08-29 в 19 15 49

$query->get() will return selection and not Carryover, below is a screenshot of how to fix it

Снимок экрана 2024-08-29 в 19 19 35
ildar-developer commented 2 weeks ago

https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-search-results.html#_ignoring_unmapped_fields

pdphilip commented 2 weeks ago

Ok the issue where starting a new query when another is in progress checks out - I'll need to run a few more tests to make sure that there are no unintended side effects with the rest of the package.

For unmapped, that's fine.

There's a PR before this one that's being worked on that brings a significant refactor to the package. I'll need to ship that one first before I can do this one. I'll let you know

ildar-developer commented 2 weeks ago

will you add unmapped too?

ildar-developer commented 2 weeks ago

thanks for the feedback

pdphilip commented 2 weeks ago

will you add unmapped too?

yes

pdphilip commented 1 week ago

@ildar-developer - an earlier PR has been merged which is a reflector of the package, so your PR is way out of sync. I'll bring in your two changes manually and tag you as a contributor on the next release.

ildar-developer commented 1 week ago

Thank you