Reputation: 943
I want to be able to match a substring using a JSON index, but I can't seem to work out how to do it.
I have a record in the data with a data.name
property of A SIGN DESIGN PTY. LTD.
. My index is defined as follows:
db.index({
name: 'subbies_text',
type: 'json',
index: {
fields: ['data.name']
},
})
Is there a selector that I can use that will perform a substring match so that I can search for "sign" or "sign design" and have "A SIGN DESIGN PTY. LTD." included in the search results?
Upvotes: 1
Views: 680
Reputation: 11
You can achieve that with "$regex". Suppose you have succeeded created a json index named "subbies_text", next is the example of the query:
{"selector": { "_id": { "$gt": 0 }, "subbies_text":{"$regex":"SIGN" } }, "fields": [ "_id", "_rev", "name" ]}
Upvotes: 1