@Test
  public void testLongs() throws Exception {
    List<Integer> docs = Arrays.asList(1, 5, 7);

    LongOpenHashSet hTerms = new LongOpenHashSet();
    List<Long> cTerms = new ArrayList<Long>(docs.size());
    for (int i = 0; i < docs.size(); i++) {
      long term = docs.get(i).longValue();
      hTerms.add(term);
      cTerms.add(term);
    }

    FieldDataTermsFilter hFilter = FieldDataTermsFilter.newLongs(getFieldData(lngMapper), hTerms);

    int size = reader.maxDoc();
    FixedBitSet result = new FixedBitSet(size);

    result.clear(0, size);
    assertThat(result.cardinality(), equalTo(0));
    result.or(hFilter.getDocIdSet(reader.getContext(), reader.getLiveDocs()).iterator());
    assertThat(result.cardinality(), equalTo(docs.size()));
    for (int i = 0; i < reader.maxDoc(); i++) {
      assertThat(result.get(i), equalTo(docs.contains(i)));
    }

    // filter from mapper
    result.clear(0, size);
    assertThat(result.cardinality(), equalTo(0));
    result.or(
        lngMapper
            .termsFilter(ifdService, cTerms, null)
            .getDocIdSet(reader.getContext(), reader.getLiveDocs())
            .iterator());
    assertThat(result.cardinality(), equalTo(docs.size()));
    for (int i = 0; i < reader.maxDoc(); i++) {
      assertThat(result.get(i), equalTo(docs.contains(i)));
    }

    hFilter = FieldDataTermsFilter.newLongs(getFieldData(dblMapper), hTerms);
    assertNull(hFilter.getDocIdSet(reader.getContext(), reader.getLiveDocs()));
  }
 @Override
 public void onValue(int docId, long value) {
   if (excluded != null && excluded.contains(value)) {
     return;
   }
   if (script != null) {
     script.setNextDocId(docId);
     script.setNextVar("term", value);
     Object scriptValue = script.run();
     if (scriptValue == null) {
       return;
     }
     if (scriptValue instanceof Boolean) {
       if (!((Boolean) scriptValue)) {
         return;
       }
     } else {
       value = ((Number) scriptValue).longValue();
     }
   }
   super.onValue(docId, value);
 }