public static void WriteIndexQuery(this BlittableJsonTextWriter writer, JsonOperationContext context, IIndexQuery query) { var indexQuery = query as IndexQueryServerSide; if (indexQuery != null) { writer.WriteIndexQuery(context, indexQuery); return; } var moreLikeThisQuery = query as MoreLikeThisQueryServerSide; if (moreLikeThisQuery != null) { writer.WriteMoreLikeThisQuery(context, moreLikeThisQuery); return; } var facetQuery = query as FacetQuery; if (facetQuery != null) { writer.WriteFacetQuery(context, facetQuery); return; } throw new NotSupportedException($"Not supported query type: {query.GetType()}"); }
public override HttpRequestMessage CreateRequest(JsonOperationContext ctx, ServerNode node, out string url) { var path = new StringBuilder(node.Url) .Append("/databases/") .Append(node.Database) .Append("/queries?op=morelikethis&query-hash=") .Append(_query.GetQueryHash(ctx)); var request = new HttpRequestMessage { Method = HttpMethod.Post, Content = new BlittableJsonContent(stream => { using (var writer = new BlittableJsonTextWriter(ctx, stream)) { writer.WriteMoreLikeThisQuery(_conventions, ctx, _query); } } ) }; url = path.ToString(); return(request); }
public void WriteContent(BlittableJsonTextWriter writer, JsonOperationContext context) { writer.WriteMoreLikeThisQuery(_conventions, context, _query); }