How to search in “all” category elements (Selector)How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory in Python?How do I sort a dictionary by value?How to make a chain of function decorators?Getting the last element of a list in PythonHow do I get the number of elements in a list in Python?How to upgrade all Python packages with pip?How do I list all files of a directory?
What to do if SUS scores contradict qualitative feedback?
Is Germany still exporting arms to countries involved in Yemen?
Is 12 minutes connection in Bristol Temple Meads long enough?
What kind of SATA connector is this?
return tuple of uncopyable objects
Why in the below sentence dative "dem" is used instead of nominative "der"?
Why are solar panels kept tilted?
Safety when modifying old electrical work
Frame adjustment for engine
Is taking modulus on both sides of an equation valid?
On studying Computer Science vs. Software Engineering to become a proficient coder
51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?
Loading Latex packages into Mathematica
Automatically anti-predictably assemble an alliterative aria
Jumping frame contents with beamer and pgfplots
Why was Thor doubtful about his worthiness to Mjolnir?
Where to find every-day healthy food near Heathrow Airport?
Anatomically Correct Carnivorous Tree
Can a tourist shoot a gun in the USA?
Does gravity affect the time evolution of a QM wave function?
How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?
Ex-manager wants to stay in touch, I don't want to
What is the largest number of identical satellites launched together?
Ito`s Lemma problem
How to search in “all” category elements (Selector)
How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory in Python?How do I sort a dictionary by value?How to make a chain of function decorators?Getting the last element of a list in PythonHow do I get the number of elements in a list in Python?How to upgrade all Python packages with pip?How do I list all files of a directory?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
my site has a search function and uses elasticsearch but currently im only able to search onto a specific category and i don't know how to make this working for all categorie-elements that exist. My target is to have a default selector set to "All" so that all categories are getting searched.
urls.py
url(r'^search/$', app_views.search_elastic, name='search'),
views.py
def search_elastic(request):
qs = request.GET.get('qs')
page = request.GET.get('page')
if qs:
post_a = Post_A_Document.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_b = Post_B_MultipleDocument.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_c = Post_C_Document.search().query("multi_match", query=qs,fields=["title", "content","tag"]).to_queryset()
qs = list(
sorted(
chain(post_a, post_b, post_c),
key=lambda objects: objects.pk
))
else:
qs = ''
paginator = Paginator(qs, 10) # Show 10 results per page
try:
qs = paginator.page(page)
except PageNotAnInteger:
qs = paginator.page(1)
except EmptyPage:
qs = paginator.page(paginator.num_pages)
return render(request, 'app/search/search_results_elastic.html', 'object_list': qs)
base.html:
<div class="search">
<form id="searchform" action="% url 'search' %" method="get" accept-charset="utf-8">
<div class="form-row align-items-center">
<input class="class-search-input-fields" id="searchbox" name="qs" required="required" type="text" placeholder="Search ..."><a>in</a>
<div class="custom-dropdown">
<a> categorysearch_form.category </a>
</div>
<button class="btn btn-outline-dark" type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</form>
</div>
python django elasticsearch
add a comment |
my site has a search function and uses elasticsearch but currently im only able to search onto a specific category and i don't know how to make this working for all categorie-elements that exist. My target is to have a default selector set to "All" so that all categories are getting searched.
urls.py
url(r'^search/$', app_views.search_elastic, name='search'),
views.py
def search_elastic(request):
qs = request.GET.get('qs')
page = request.GET.get('page')
if qs:
post_a = Post_A_Document.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_b = Post_B_MultipleDocument.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_c = Post_C_Document.search().query("multi_match", query=qs,fields=["title", "content","tag"]).to_queryset()
qs = list(
sorted(
chain(post_a, post_b, post_c),
key=lambda objects: objects.pk
))
else:
qs = ''
paginator = Paginator(qs, 10) # Show 10 results per page
try:
qs = paginator.page(page)
except PageNotAnInteger:
qs = paginator.page(1)
except EmptyPage:
qs = paginator.page(paginator.num_pages)
return render(request, 'app/search/search_results_elastic.html', 'object_list': qs)
base.html:
<div class="search">
<form id="searchform" action="% url 'search' %" method="get" accept-charset="utf-8">
<div class="form-row align-items-center">
<input class="class-search-input-fields" id="searchbox" name="qs" required="required" type="text" placeholder="Search ..."><a>in</a>
<div class="custom-dropdown">
<a> categorysearch_form.category </a>
</div>
<button class="btn btn-outline-dark" type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</form>
</div>
python django elasticsearch
add a comment |
my site has a search function and uses elasticsearch but currently im only able to search onto a specific category and i don't know how to make this working for all categorie-elements that exist. My target is to have a default selector set to "All" so that all categories are getting searched.
urls.py
url(r'^search/$', app_views.search_elastic, name='search'),
views.py
def search_elastic(request):
qs = request.GET.get('qs')
page = request.GET.get('page')
if qs:
post_a = Post_A_Document.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_b = Post_B_MultipleDocument.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_c = Post_C_Document.search().query("multi_match", query=qs,fields=["title", "content","tag"]).to_queryset()
qs = list(
sorted(
chain(post_a, post_b, post_c),
key=lambda objects: objects.pk
))
else:
qs = ''
paginator = Paginator(qs, 10) # Show 10 results per page
try:
qs = paginator.page(page)
except PageNotAnInteger:
qs = paginator.page(1)
except EmptyPage:
qs = paginator.page(paginator.num_pages)
return render(request, 'app/search/search_results_elastic.html', 'object_list': qs)
base.html:
<div class="search">
<form id="searchform" action="% url 'search' %" method="get" accept-charset="utf-8">
<div class="form-row align-items-center">
<input class="class-search-input-fields" id="searchbox" name="qs" required="required" type="text" placeholder="Search ..."><a>in</a>
<div class="custom-dropdown">
<a> categorysearch_form.category </a>
</div>
<button class="btn btn-outline-dark" type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</form>
</div>
python django elasticsearch
my site has a search function and uses elasticsearch but currently im only able to search onto a specific category and i don't know how to make this working for all categorie-elements that exist. My target is to have a default selector set to "All" so that all categories are getting searched.
urls.py
url(r'^search/$', app_views.search_elastic, name='search'),
views.py
def search_elastic(request):
qs = request.GET.get('qs')
page = request.GET.get('page')
if qs:
post_a = Post_A_Document.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_b = Post_B_MultipleDocument.search().query("multi_match", query=qs, fields=["title", "content", "tag"]).to_queryset()
post_c = Post_C_Document.search().query("multi_match", query=qs,fields=["title", "content","tag"]).to_queryset()
qs = list(
sorted(
chain(post_a, post_b, post_c),
key=lambda objects: objects.pk
))
else:
qs = ''
paginator = Paginator(qs, 10) # Show 10 results per page
try:
qs = paginator.page(page)
except PageNotAnInteger:
qs = paginator.page(1)
except EmptyPage:
qs = paginator.page(paginator.num_pages)
return render(request, 'app/search/search_results_elastic.html', 'object_list': qs)
base.html:
<div class="search">
<form id="searchform" action="% url 'search' %" method="get" accept-charset="utf-8">
<div class="form-row align-items-center">
<input class="class-search-input-fields" id="searchbox" name="qs" required="required" type="text" placeholder="Search ..."><a>in</a>
<div class="custom-dropdown">
<a> categorysearch_form.category </a>
</div>
<button class="btn btn-outline-dark" type="submit">
<i class="fa fa-search"></i>
</button>
</div>
</form>
</div>
python django elasticsearch
python django elasticsearch
asked Mar 23 at 12:57
VenomVenom
100110
100110
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313952%2fhow-to-search-in-all-category-elements-selector%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313952%2fhow-to-search-in-all-category-elements-selector%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown