Sequential keyword searching?

Is it possible with ElasticSearch to search for a keyword or phrase AFTER a different keyword has been found?

for example, document with field "text" has value of "this is a test document".

I need to be able to find it based on "thisdocument" or "thistest".

Do span queries fit the bill for your use case?

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html

span_near query got me really really close, but the problem I was running into was that phrases were not working?

the following was as close as I was getting

                            foreach($arrKeywords[$i] as $strKeyword)
				{
					$arrClauses[] = ['span_term' => ['transcript' => '"'.$strKeyword.'"']];
				}

				$objQuery->query->bool->should[]->span_near = [
				    'clauses' => $arrClauses,
				    'slop' => 100000000,
				    'in_order' => true
				];

I know this won't solve your solution, but that slop value is a bit hectic.

I agree Walkom, I am trying to accomplish a task without the right tool it feels.

I want to find a keyword in a block of text and then search for another keyword that only happens after the previous keyword was found. This was the closest solution I could come up with but phrases are not working, only terms.