Skip to main content

Querying hidden fields

Comments

4 comments

  • Matt Kearse

    Unfortunately hidden fields are not indexed for searching by design. Sorry about the lack of documentation on this, we'll improve that.

    The best I can suggest for a work-around is to change your fields to be not visible by default and non-editable by replacing  

    DocumentField recordIdField = DocumentField.createStringField(
        RECORD_ID_FIELD_NAME,
        RECORD_ID_FIELD_DESCRIPTION,
        RECORD_ID_FIELD_ID);

    with

    DocumentField recordIdField = new DocumentField(
        RECORD_ID_FIELD_NAME,
        RECORD_ID_FIELD_DESCRIPTION,
        RECORD_ID_FIELD_ID,
        String.class,
        false,
        false);

    Alternatively, if you're implementing your own PluginDocument class (which is a lot more involved and I wouldn't recommend it unless you really need to), there's the AdditionalSearchContent interface that PluginDocuments may implement to provide search content for data which is not stored as a field.

    0
  • Guzman

    Yes, however, setting the fields as non-editable doesn't prevent the user from actually modifying those fields, it just throws a warning. Is that correct? 

    0
  • Matt Kearse

    Yes, that's correct that they will see this warning

    This value is read-only because it has been provided by a database or operation. Are you sure you want to change it?

    But they can go ahead with editing it anyway. I don't think there's a way to prevent that unless you happen to be viewing documents in a PartiallyWritableDatabaseService, in which case you could use PartiallyWritableDatabaseService.canEditDocumentField, but if you aren't already using a PartiallyWritableDatabaseService that won't help.

    0
  • Guzman

    Sounds good, thanks. Would be a good feature to have.

    Guzman

    0

Please sign in to leave a comment.