Skip to content

Instantly share code, notes, and snippets.

@kparms
Created May 5, 2014 16:54
Show Gist options
  • Save kparms/7ee521e78aa9a5f9a76d to your computer and use it in GitHub Desktop.
Save kparms/7ee521e78aa9a5f9a76d to your computer and use it in GitHub Desktop.
Powershell to get all tags from a specified index engine in Decisiv
#Search command will return all tags for the specified index engine
$runningCommand = "search -project singleMindServer.IPS -user admin -password [adm pw] -hasTaxonomy doc_tag -pagesize 100000000 -field doc_tag"
$runningProcs = cmd /c $runningCommand
#These search strings will return an array of documents and tags, which is part of the search output
$documents = @($runningProcs -like "*with raw score*") | Foreach {$_.Trim()}
#$tags = @($runningProcs -like "*doc_tag (type=field)*") | Foreach {$_.Trim()}
$strResponse = -join $runningProcs
#We use a regex match to get all tags from the index
$tags = Select-String "<field[^>]+>(.*?)</field>" -input $strResponse -AllMatches | % {$_.matches} | % {$_.Groups[1].Value.Trim()}
$tags = $tags | select -uniq
$tags | write-host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment