Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-4374

Solr could not support numeric field name in return

    XMLWordPrintableJSON

Details

    Description

      When using numeric field name in schema.xml, like

      <field name="1001" type="string"...>

      , it could not be fetched the specific field name by parameter 'fl' from Solr.
      such as 'http://localhost:8983/solr/query?q=1001:test&fl=1001', the response would be like: '"docs""[

      {"1001":1001,...}

      ,...]'
      In org.apache.solr.search.ReturnFields.java, it seems this code limited field name defination could not be pure numbers:

      org.apache.solr.search.ReturnFields.java
      // like getId, but also accepts dashes for legacy fields
        String getFieldName(QueryParsing.StrParser sp) {
          sp.eatws();
          int id_start = sp.pos;
          char ch;
          if (sp.pos < sp.end && (ch = sp.val.charAt(sp.pos)) != '$' && Character.isJavaIdentifierStart(ch)) {
            sp.pos++;
            while (sp.pos < sp.end) {
              ch = sp.val.charAt(sp.pos);
              if (!Character.isJavaIdentifierPart(ch) && ch != '.' && ch != '-') {
                break;
              }
              sp.pos++;
            }
            return sp.val.substring(id_start, sp.pos);
          }
      
          return null;
        }
      

      Could we replace or remove this check of Character.isJavaIdentifierStart(ch) for allowing numeric field name defination?

      Attachments

        Activity

          People

            Unassigned Unassigned
            qun Qun Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: