Elasticsearch cache

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

  • ZeroXT
  • Registratie: December 2007
  • Laatst online: 06-10 22:21
Hallo allen,

Ik heb een klantenoverzicht waarin een klant (of meerdere) middels een XHR request verwijderd kan worden. De onderstaande code gebruik ik om de klant(en) te markeren als verwijderd in Elasticsearch.


PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public function update($customers) {
    
    $params = ['body' => []];

    foreach($customers as $customer) {
        
        $params['body'][] = [

            'index' => [

                '_index' => 'customers',
                '_type'  => 'customer',
                '_id'    => $customer['id']
            ]
        ];

        $params['body'][] = $customer;
    }

    return $this -> getAdapter() -> bulk($params);
}


Ik maak gebruik van de volgende library om de bulk method uit te voeren:
https://www.elastic.co/gu...nt/php-api/6.0/index.html

Direct nadat ik response krijg dat de bulk update gelukt is, haal ik alle klanten weer op. Maar tot mijn verbazing zitten daar de klant(en) tussen die net gemarkeerd zijn als verwijderd.

Wanneer ik een php sleep(1) uitvoer voordat ik de klanten opnieuw ophaal nadat deze verwijderd zijn, is het resultaat zoals verwacht.

Iets zegt me dat Elasticsearch nog iets in de cache heeft staan welke niet direct verwijderd is.

Heeft iemand enig idee hoe ik ervoor kan zorgen dat wanneer de klanten gemarkeerd worden als verwijderd (of definitief verwijderd worden, want daar gebeurd precies hetzelfde), ik niet de oude "cache" klanten ophaal?

Beste antwoord (via ZeroXT op 04-05-2018 15:05)


  • pachacuti
  • Registratie: Januari 2002
  • Laatst online: 14-09 12:40
Is dit mss het probleem?

https://www.elastic.co/gu...rrent/near-real-time.html
In Elasticsearch, this lightweight process of writing and opening a new segment is called a refresh. By default, every shard is refreshed automatically once every second. This is why we say that Elasticsearch has near real-time search: document changes are not visible to search immediately, but will become visible within 1 second.

This can be confusing for new users: they index a document and try to search for it, and it just isn’t there. The way around this is to perform a manual refresh, with the refresh API:

Alle reacties


Acties:
  • Beste antwoord
  • 0 Henk 'm!

  • pachacuti
  • Registratie: Januari 2002
  • Laatst online: 14-09 12:40
Is dit mss het probleem?

https://www.elastic.co/gu...rrent/near-real-time.html
In Elasticsearch, this lightweight process of writing and opening a new segment is called a refresh. By default, every shard is refreshed automatically once every second. This is why we say that Elasticsearch has near real-time search: document changes are not visible to search immediately, but will become visible within 1 second.

This can be confusing for new users: they index a document and try to search for it, and it just isn’t there. The way around this is to perform a manual refresh, with the refresh API: