>Awesome, 0 pre and 1 post works! Great!
> What if I wanted to match thirty, but exclude if six or seven are included > anywhere in the document? Any time you need "anywhere in the document", use a "regular" query (not SpanQuery). As you wrote initially, you can construct a BooleanQuery that includes a complex SpanQuery and another Query that is BooleanClause.Occur.MUST_NOT. > I also tried 0 pre and 0 post You'd use those if you wanted to find something that didn't contain something else: ["William Clinton"~2 Jefferson]!~0,0 Find 'william' within two words of 'clinton', but not if 'jefferson' appears between them. > I replaced pre with Integer.MAX_VALUE and post with Integer.MAX_VALUE - 5 and > it works! I'll have to think about this one...