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
Create index without importing if reindexing by individual records only #747
Comments
This use case seems pretty uncommon, so I don't think it belongs in the readme, but we could improve the error message. |
Thanks. Even though it's an uncommon use case, is it still acceptable for I'll look into how to improve the error message. |
I'm actually working on the same problem. We have a very large set of data to index and I need to provide progress of the reindex back to my users. To accomplish this I was going to do as you did above and send the progress as each batch is reindexed. I'm just worried that once I call |
@jimmybaker I assume that as soon as you run |
One thing to bear in mind when using I'm unsure if there's a way to reindex after changing a Searchkick setting with Edit: |
@ankane do you think we should update the readme to include something along the lines of: If you are reindexing by individual records only, then you should create the index first without importing (ie
Product.reindex(import: false)
) so the Searchkick settings in your model are applied ?Background
I've had a lot of issues with how I use default scopes in my multitenant app, and how I
reindex
my data with Searchkick. A full discussion of the problem can be found here, but the end solution was to usereindex
on individual records rather than the model as a whole. An example of my custom rake task to reindex would look like:This works for me at the moment and allows me to use
search_data
without using.joins
withunscoped
as I can daisy chain through the models that are scoped.I ran into a problem when I decided I would like to
match
ontext_start
on a column that was already existing in the index. I added the codematch
code to my model:I reindexed and included it in my search:
.search(query, fields: [{model_number: :text_start}])
, however, I could not get it to work. Looking at the field in Kibana I saw two entries:I thought having two entries may be an issue so I thought I would start fresh and delete all of my indices with:
curl -XDELETE 'http://localhost:9200/_all/'
After
reindexing
the individual record I tried to search usingtext_start
and would get the following:Searchkick::InvalidQueryError: [400] {"error":{"root_cause":[{"type":"query_parsing_exception","reason":"[match] analyzer [searchkick_autocomplete_search] not found","index":"services_development",
From this I realised that the numbers usually appended to my index name by Searchkick were not present. I then deleted the index again and this time created it with
Service.reindex(import: false)
, usingcurl 'localhost:9200/_cat/indices?v'
showed the index was created with the appended numbers. Using this already created index I then usedreindex
on the individual record and this time when I performed my search withtext_start
I was able to obtain results correctly.The text was updated successfully, but these errors were encountered: