babenkoivan / elastic-scout-driver-plus

Extension for Elastic Scout Driver
MIT License
267 stars 52 forks source link

Syncing data inside tests #132

Closed dsindrilaru closed 2 years ago

dsindrilaru commented 2 years ago
Software Version
PHP 8.1
Elasticsearch 8.3.3
Laravel 9.22.1
Laravel Scout 9.4.10
Elastic Scout Driver 3.0.0
Elastic S.D. Plus. 4.0.0

Describe the bug Not necessarily a bug, but I'm writing some tests in order to test my filters. I have a filter which should only return entities with titles containing some word. For this test, I create 2 fake entities, then apply the filter which should only return 1 one of them, but I get nothing back. After some debugging, it seems like the entities don't get to the elastic server. I manually sync them, but then the test only works if I specify size(50), otherwise there are only 10 results indexed. I looked over the tests in your package and I see you only create dummy data using factories and the assertions work as desired. Can you please let me know whether there is some other config I need to do? Thanks!

babenkoivan commented 2 years ago

Hi @dsindrilaru, I think I need more details to understand the issue.

Do you use a real ES server in your tests? If so, you should probably set elastic.scout_driver.refresh_documents config to true, otherwise documents are indexed with a delay.

If this doesn't solve your issue, can you please provide your test case code and how you create the entities?

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days