Even if you delete all docs using deleteByQuery api and start indexing
using the code in your email, index will still identify as being created in
7.x. So as Shawn mentioned, the only solution is to bring down the solr
service, delete the "index" and "tlogs" folder, bring up the service again
and run the code to repopulate the index.
Lucene maintains a version stamp called "indexCreatedVersionMajor" in the
segments_* file which carries forward between commits which is how it is
able to know whether an index was "ever touched" by a version < (your
version)-1.

To know whether your index has been "legitimately" converted to an 8.x
index after reindexing, you could call this /segments api:

localhost:8983/solr/<core_name>/admin/segments

It contains this version stamp for each segment. Look for "
*createdVersionMajor*" Eg:
 "_pp0":{
      "name":"_pp0",
      "delCount":0,
      "softDelCount":0,
      "hasFieldUpdates":false,
      "sizeInBytes":39123,
      "size":1,
      "age":"2023-08-23T13:11:51.076Z",
      "source":"flush",
      "version":"8.11.1",
      *"createdVersionMajor":8,*
      "minVersion":"8.11.1",
      "diagnostics":{
        "java.vendor":"Eclipse Adoptium",
        "os":"Linux",
        "java.version":"17.0.5",
        "java.vm.version":"17.0.5+8",
        "lucene.version":"8.11.1",
        "os.arch":"amd64",
        "java.runtime.version":"17.0.5+8",
        "source":"flush",
        "os.version":"4.18.0-383.el8.x86_64",
        "timestamp":"1692796311076"},
      "attributes":{"Lucene87StoredFieldsFormat.mode":"BEST_SPEED"}}}}


-Rahul



On Thu, Aug 24, 2023 at 4:39 PM Shawn Heisey <apa...@elyograg.org> wrote:

> On 8/24/23 14:02, Christopher Schultz wrote:
> > I'm preparing to upgrade a standalone Solr server from 7.7.3 -> 8.11.2
> > and I wanted to confirm a few things.
> >
> > First, I'm assuming that the new server will be willing to open and
> > modify the existing index after the upgrade, because I haven't seen
> > anything to suggest that wouldn't be the case, but please let me know if
> > I'm wrong about that.
>
> If the index was EVER touched by a version before 7.0, then 8.x will not
> read it.  If the index was built from scratch by 7.7.3, then it will work.
>
> > Second, I understand that a complete re-index is appropriate, and that
> > if I were to eventually upgrade to Solr 9 (which is also in the plan), I
> > would have to ensure that the index has been "properly" upgraded to an
> > 8.x-style index in order for Solr 9 to open it and re-index, etc.
>
> Version 9 behaves the same as 8.  If the index was ever touched by a
> version before 8.0, version 9 will not read the index.
>
> I would strongly recommend that even if your existing index will work,
> that you perform a complete re-index from scratch as soon as possible.
>
> > I'm using a Java-based process via SolrJ to perform the re-index. My
> > re-index process looks something like this:
> >
> > 1. (Optional) solr.deleteByQuery("*:*")
> > 2. for each document :
> >   2a. SolrInputDocument doc = new SolrInputDocument();
> >       doc.addField("id", primary-identifier);
> >       ...
> >   2b. solr.add(doc)
> >
> > Is the above enough to generate a "new" 8.x-style index that will be
> > acceptable in the future? Is it necessary to perform step (1) and delete
> > all documents first, or if I freshen ALL documents will I end up with a
> > completely new index?
>
> Before running that, you will want to either build a brand new core or
> completely delete all index* directories in the core then reload that
> core.  If you do that, then there will be no possibility of
> "contamination" from an earlier version.
>
> > Is there a way I can inspect the index afterward to ensure I've been
> > successful? Some kind of magic-number in file headers or an API call I
> > can make to ask about the version-ness of the index?
>
> The Lucene tool called "Luke" can probably give you that information for
> each segment.  I do not know enough about low-level Lucene file formats
> to give you a definitive answer.
>
> Thanks,
> Shawn
>

Reply via email to