次の3つのテーブルがあります。
documents (id, content)
words (id, word)
word_document (word_id, document_id, count)
単語テーブルには、すべてのドキュメントで発生したすべての単語が含まれ、word_documentは、単語をドキュメントに関連付け、そのドキュメント内のその単語の数を関連付けます。
2つの単語を検索するクエリを作成し、ドキュメント内の両方の単語の数の合計で順序付けられた両方の単語を持つドキュメントのみを返します。
例えば
DocA: green apple is not blue
DocB: blue apple is blue
DocC: red apple is red
アップルとブルーを検索すると、次のようになります。
DocA, 3
DocB, 2
なぜなら:
DocA contains both words and 3 of them
DocB contains both words and 2 of them
DocC only contains one word
交差を正常に使用しましたが、カウントの合計と順序が返されません。