CanastaWiki / Canasta-CLI

The Canasta command line interface, written in Go
MIT License
5 stars 14 forks source link

Add "canasta elasticsearch index" command #41

Open yaronkoren opened 1 year ago

yaronkoren commented 1 year ago

It would be good to have a "canasta elasticsearch index" command. This would, of course, only be usable if Elasticsearch and the CirrusSearch extension are installed. I'm told the set of actual commands it should call is:

maintenance/UpdateSearchIndexConfig.php maintenance/ForceSearchIndex.php --skipLinks --indexOnSkip maintenance/ForceSearchIndex.php --skipParse

...all within the CirrusSearch/ directory. I don't know if that's correct, but it seems like a good starting point.

Potentially there could be other "elasticsearch" sub-commands that it would be useful to have in the future.

jeffw16 commented 1 year ago

That is correct. Maybe add a --force flag (or whatever it's called) to UpdateSearchIndexConfig.php too.

olsonjaredm commented 1 year ago

Here are a few commands I use to check the health of ES; not sure if it's helpful, maybe could be incorporated into the new command:

curl -X GET "localhost:9200/_count?pretty" -H 'Content-Type: application/json' -d'
{
    "query": {
        "match_all": {}
    }
}
'

or

curl -X GET "localhost:9200/_cluster/health?pretty"

Gives you some basic info on the cluster/shards and a green/yellow/red health status.

For reference, the index command should print out the script results. I think this is your intent: i.e.:


root@5eaf6089ecd2:/var/www/mediawiki/w# php canasta-extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php
indexing namespaces...
        Indexing namespaces...done
content index...
        Fetching Elasticsearch version...6.8.20...ok
        Scanning available plugins...none
        Picking analyzer...english
        Inferring index identifier...minerva_content_first
                Validating number of shards...ok
                Validating replica range...ok
                Validating shard allocation settings...done
                Validating max shards per node...ok
        Validating analyzers...ok
        Validating mappings...
                Validating mapping...ok
        Validating aliases...
                Validating minerva_content alias...ok
                Validating minerva alias...ok
                Updating tracking indexes...done
general index...
        Fetching Elasticsearch version...6.8.20...ok
        Scanning available plugins...none
        Picking analyzer...english
        Inferring index identifier...minerva_general_first
                Validating number of shards...ok
                Validating replica range...ok
                Validating shard allocation settings...done
                Validating max shards per node...ok
        Validating analyzers...ok
        Validating mappings...
                Validating mapping...ok
        Validating aliases...
                Validating minerva_general alias...ok
                Validating minerva alias...ok
                Updating tracking indexes...done
archive index...
        Fetching Elasticsearch version...6.8.20...ok
        Scanning available plugins...none
        Picking analyzer...english
        Inferring index identifier...minerva_archive_first
                Validating number of shards...ok
                Validating replica range...ok
                Validating shard allocation settings...done
                Validating max shards per node...ok
        Validating analyzers...ok
        Validating mappings...
                Validating mapping...ok
        Validating aliases...
                Validating minerva_archive alias...ok
                Updating tracking indexes...done
amalpaul54111 commented 1 year ago

That is correct. Maybe add a --force flag (or whatever it's called) to UpdateSearchIndexConfig.php too.

Couldn't find a --force flag. Instead found --startOver: Blow away the identified index and rebuild it with no data. Is this the right one?

jeffw16 commented 1 year ago

Yes, it's --startOver

chl178 commented 1 year ago

@jeffw16 I'm interested in working on this. Could you please assign it to me?

jeffw16 commented 1 year ago

@chl178 Assigned