Azure CosmosDB Mongoを使用しています。WHERE句Azure CosmosDB Mongoサブ文書
私は文書とサブ文書にテキストフィールドを持っています。私は検索できるようにしたい。
Contains
を使用すると、親ドキュメントのプロパティで正常に動作します。しかし、子供たちをまったく見ていないようです。そして、どんなエラーも返さない。
ドキュメント:
{
"TextField1": "this will be found in search",
"Comments": [{
"Comment": "amazing post, let's see if this can be foundtoo",
}, {
"Comment": "thanks",
}]
}
検索:
var postFilter = Builders<MyObject>.Filter.Where(p => p.TextField1.ToLowerInvariant().Contains(searchText.ToLowerInvariant())) |
Builders<MyObject>.Filter.Where(p => p.Comments.Any(pc => pc.Comment.ToLowerInvariant().Contains(searchText.ToLowerInvariant())));
var posts = await Posts.Find(postFilter).ToListAsync();
私は "見つけ" 検索で上記のコードを使用している場合。文書を返します。
「foundtoo」という検索で使用するとします。何も返されません。
PS:私はText
を使用しようとしましたが、サポートされていません、エラーとして戻ってきます。
感謝。試してみましょう。 – Yahya
あなたはスターです! – Yahya