FeaturePath beginPath = cas.createFeaturePath();
beginPath.addFeature(annotationType.getFeatureByBaseName("begin"));
FSIntConstraint beginConstraint = cf.createIntConstraint();
beginConstraint.geq(span.getStart());
FSMatchConstraint embeddedBegin = cf.embedConstraint(beginPath, beginConstraint);
FeaturePath endPath = cas.createFeaturePath();
endPath.addFeature(annotationType.getFeatureByBaseName("end"));
FSIntConstraint endConstraint = cf.createIntConstraint();
endConstraint.leq(span.getEnd());
FSMatchConstraint embeddedEnd = cf.embedConstraint(endPath, endConstraint);
FSMatchConstraint strictType = new StrictTypeConstraint(type);
FSMatchConstraint annotatioInSpanConstraint = cf.and(embeddedBegin, embeddedEnd);
FSMatchConstraint annotationInSpanAndStrictTypeConstraint =
cf.and(annotatioInSpanConstraint, strictType);
FSIndex<AnnotationFS> allAnnotations = cas.getAnnotationIndex(type);
FSIterator<AnnotationFS> annotationInsideSpanIndex =