Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please support Inclusion and exclusion of fields #1765

Open
hktalent opened this issue Dec 5, 2022 · 2 comments
Open

please support Inclusion and exclusion of fields #1765

hktalent opened this issue Dec 5, 2022 · 2 comments

Comments

@hktalent
Copy link

hktalent commented Dec 5, 2022

Inclusion and exclusion of fields
E.g
I want to check
tags:leak but no field:
passwd
doc, do not know how to write

Two docs are now indexed
1

tags: leak
xxx
...
}
  1. There is no tags (field)
{
name: leak
xxx
...
}

Now I want to be able to query the doc without tags, probably like this

@abhinavdangeti
Copy link
Member

abhinavdangeti commented Dec 5, 2022

@hktalent if you expect help with your issues, we'll need you to be a bit more descriptive when you log issues.

I'm not really sure what you mean by inclusion and exclusion of fields. Sharing a sample document here would help us more in understanding what it is you're trying to achieve.

Bleve does support field agnostic search, for field data that you've included into the composite (_all) field. For example if you define your index mapping to add the field tags and also include it within the composite field (_all), then the following searches would work ..

1. tags:leak
2. leak

If that wasn't your question at all, and your question was more on how to index document content when there is no concept of a field, like in this example:

[
    "abc"
]

Here's how you can index and search for abc ..

	idxMapping := NewIndexMapping()
	idx, err := New("testidx", idxMapping)
	if err != nil {
		panic(err)
	}
	
	defer func() {
		err = idx.Close()
		if err != nil {
			panic(err)
		}
	}()

	one := []byte(`["abc"]`)

	var doc interface{}
	if err = json.Unmarshal(one, &doc); err != nil {
		panic(err)
	}

	if err = idx.Index("doc", doc); err != nil {
		panic(err)
	}

	q := query.NewTermQuery("abc")
	sr := NewSearchRequest(q)

	searchResults, err := idx.Search(sr)
	if err != nil {
		panic(err)
	}

	if searchResults == nil || len(searchResults.Hits) != 1 || searchResults.Hits[0].ID != "doc" {
                panic("unexpected")
        }

@hktalent
Copy link
Author

hktalent commented Dec 6, 2022

Inclusion and exclusion of fields E.g I want to check tags:leak but no field: passwd doc, do not know how to write

Two docs are now indexed 1

tags: leak
xxx
...
}
  1. There is no tags (field)
{
name: leak
xxx
...
}

Now I want to be able to query the doc without tags, probably like this

@abhinavdangeti Thank you very much

image

That is, the query contains +leaks But there is no documentation for the tags field in the doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants