Get tokens from Index Analyzer and copy to string field

Viewed 24

The idea is that I have a name_s (solr.TextField) field with Index Analyzer with stopwords and lower case filters. I want to get the output of the Index Analyzer and copy to a string field name_x, as a single string. Is this possible?

Example

Input for name_s: The red brown fox was actually black.
_____________________________________________
Index Analyzed for name_s:
red
brown
fox
black

_____________________________________________
Now input inside of name_x: red brown fox black
1 Answers

I don't think there is a way to accomplish exactly what you are trying to do (saving the individual tokes from one field into another), but if you just want to inspect how a particular field was processed you can cheat and use the facets to get this information.

For example, let's say that I have a Text field with the following information on a document with id "00000004":

"id":"00000004",
"title_txt_en":"Personal rights and the domestic relations /

Then I can output the individual tokens stored in title_txt_en for this individual record by faceting by this field using a query like this:

# q=id:00000004
# facet.field=title_txt_en
# f.title_txt_en.facet.mincount=1
curl http://localhost:8983/solr/your-core/select?f.title_txt_en.facet.mincount=1&facet.field=title_txt_en&facet=on&q=id%3A00000004

The response will include the following:

"facet_counts":{
    "facet_queries":{},
    "facet_fields":{
      "title_txt_en":[
        "domest",1,
        "person",1,
        "relat",1,
        "right",1]}

where you can see the individual tokens that were indexed: "domest", "person", "relat", and "right" for this field in this record.

As I said, not an exact answer to what you are looking for, but hopefully it helps.

Related