0

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?

javamonkey79
  • 17,443
  • 36
  • 114
  • 172

2 Answers2

0

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.

femtoRgon
  • 32,893
  • 7
  • 60
  • 87
  • I agree with the sentiment that this is an oddly named field, but it is something I inherited and cannot change. – javamonkey79 Sep 19 '14 at 20:53
  • I just tried your suggestion and it does not work. It does not error out, but it also does not return the field in the documents. – javamonkey79 Sep 19 '14 at 20:56
  • Yeah, wasn't quite sure I had it just right, honestly. Not in a position to test it out at the moment. Fairly sure something close to that will work. Might see if I can work that out later. – femtoRgon Sep 19 '14 at 22:20
0

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.

Community
  • 1
  • 1
javamonkey79
  • 17,443
  • 36
  • 114
  • 172