Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr: Retrieve field names from a solr index?

Tags:

solr

How can I query a Solr instance for all (or prefixed) field names?

I want to use dynamic fields where I do not know how many may exist e.g: category_0_s, category_1_s etc.

Preferably I'd like to use a prefix e.g. category_

like image 660
floplus Avatar asked Sep 09 '25 16:09

floplus


1 Answers

This query will return a comma-separated list of all the fields that are in use, including dynamic ones.

select?q=*:*&wt=csv&rows=0&facet

To answer the original question, this is how to get a list of all the fields starting with category_

select?q=*:*&wt=csv&rows=0&facet&fl=category_*

The presence of the facet parameter is needed to make this query work on newer versions of Solr. On older versions, it will work without it.

On older versions, a wildcard in the fl parameter won't work.

like image 99
GoalBased Avatar answered Sep 13 '25 06:09

GoalBased