简体   繁体   中英

solr field limit, field with “|”

I have a dynamic field: mappings_|int-color| that obviously contains "|" characters and causes this when I include it in a field limit:

<lst name="error">
  <str name="msg">Error parsing fieldname: Expected identifier at pos 0 str='|int-color|'</str>
  <int name="code">400</int>
</lst>

Is there a way to field limit (fl) fields that contain "|" characters?

I believe you can do this by wrapping your oddball field name in single quotes, and using the field function, something like:

field('mappings_|int-color|')

But, of course, I'd bet you can guess at the real solution.

Solr allows you to set field names to whatever you please, just as lucene itself does. And they are also similar in that, if you assign complex names to fields like this, you're kind of asking for pain. Goofy hacks like this for instance. So don't do that thing up above, sanitize your field names. You can't go too wrong if you stick to Java identifier rules for your field names.

A colleague pointed me at this related question , which inevitably led me to try wildcard-ing the unacceptable chars.

This worked for me: mappings_*int*color*

Granted, it catches a few extra fields, but works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM