How to obtain a list of documents which contain all words from a query? [not intersection]
<p>I'm working using Python.</p>

<p>I have a query, with words. For example, query=[hello, tree, blue] </p>

<p>I've selected for each word in which documents it is, so I have a list for each word, where each position is one of the documents. Let's say:</p>

<pre><code>list_query[0]=[1,4,5]
list_query[1]=[5,8]
list_query[2]=[4,5,8]
</code></pre>

<p>So, I should get a result = [5]</p>

<p>But, I don't wanna do it using intersection. I need to do it using iterations, i, j.</p>

<pre><code>hello:
      i
      |
      1    4    5
tree:
      5    8
      |
      j
</code></pre>

<p>I'll have to start with i=0, compare if the list_query[0][i]==list_query[1][j], if so add that number to the list. If not I should iterate the smaller number of boths iterators, and so on, with the result of that intersection of those lists and the rest of the elements of the query. But kind find how to do it and it's driving me mad.</p>

<p>So if anyone could help me...
Thanks in advance.</p>
