@Override
  public PropertySet getPropertySetByURI(Path uri) throws IndexException {
    PropertySet propSet = null;

    try {
      List<Document> docs =
          lookupDocs(new Term(ResourceFields.URI_FIELD_NAME, uri.toString()), null);
      if (docs.size() > 0) {
        Document doc = docs.get(0); // Just pick first in case of duplicates
        propSet = mapper.getPropertySet(doc);
      }
    } catch (IOException io) {
      throw new IndexException(io);
    }

    return propSet;
  }
  @Override
  public int countInstances(Path uri) throws IndexException {

    Term term = new Term(ResourceFields.URI_FIELD_NAME, uri.toString());
    try {
      List<Document> docs =
          lookupDocs(
              term,
              new LoadFieldCallback() {
                @Override
                public boolean loadField(String fieldName) {
                  return false;
                }
              });
      return docs.size();
    } catch (IOException io) {
      throw new IndexException(io);
    }
  }
  @Override
  public PropertySetInternalData getPropertySetInternalData(final Path uri) throws IndexException {

    try {
      LoadFieldCallback lfc =
          new LoadFieldCallback() {
            @Override
            public boolean loadField(String fieldName) {
              if (ResourceFields.URI_FIELD_NAME.equals(fieldName)
                  || ResourceFields.RESOURCETYPE_FIELD_NAME.equals(fieldName)
                  || ResourceFields.ID_FIELD_NAME.equals(fieldName)) {
                return true;
              }
              if (fieldName.startsWith(AclFields.ACL_FIELD_PREFIX)) {
                return true;
              }

              return false;
            }
          };

      List<Document> docs =
          lookupDocs(new Term(ResourceFields.URI_FIELD_NAME, uri.toString()), lfc);
      if (docs.isEmpty()) return null;

      Document doc = docs.get(0); // Just pick first in case of duplicates
      final String rt = doc.get(ResourceFields.RESOURCETYPE_FIELD_NAME);
      final int id = ResourceFields.getResourceId(doc);
      final int aclInheritedFrom = AclFields.aclInheritedFrom(doc);
      final Acl acl = mapper.getAclFields().fromDocument(doc);

      return new PropertySetInternalData() {
        @Override
        public Path getURI() {
          return uri;
        }

        @Override
        public String getResourceType() {
          return rt;
        }

        @Override
        public int getResourceId() {
          return id;
        }

        @Override
        public int getAclInheritedFromId() {
          return aclInheritedFrom;
        }

        @Override
        public Acl getAcl() {
          return acl;
        }
      };
    } catch (IOException io) {
      throw new IndexException(io);
    }
  }