2

Right now I wrote

Tire.search INDEX_NAME do
  query do
    filtered do
      query { string term }
      filter :or, { missing: { field: :app_id } },
                  { terms: { app_id: app_ids } }
    end
  end
end.results.to_a

1 Answer 1

1

Well returning items that either have no app_id or one that matches your terms sounds like a job for an or filter - I'd try

filter :or, [
    {:not => {:exists => {:field => :app_id}}},
    {:terms => {:app_id => app_ids}}
  ]
Sign up to request clarification or add additional context in comments.

2 Comments

You solution has any advantages over my missing filter? filter :or, { missing: { field: :app_id } }
Don't think so, although your missing thing easn't there when I wrote my post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.